Skip to content

Webhooks JavaScript

BL edited this page Dec 9, 2017 · 1 revision

Usage

export TRELLO_API_KEY=KEY
export TRELLO_OAUTH_TOKEN=TOKEN

Configuration

Set your Trello Api Key and Trello Auth Token.

var Trello = require('trello-node-api')(TRELLO_API_KEY, TRELLO_OAUTH_TOKEN);

Webhooks

Create webhook

    var data = {
        description: 'Webhook description',
        callbackURL: 'https://mycallbackurl.com/', // REQUIRED
        idModel: 'MODEL_ID', // REQUIRED
        active: false
    };
    Trello.webhook.create(data).then(function (response) {
        console.log('response ', response);
    }).catch(function (error) {
        console.log('error', error);
    });

Search webhook

    Trello.webhook.search('WEBHOOK_ID').then(function (response) {
        console.log('response ', response);
    }).catch(function (error) {
        console.log('error', error);
    });

Search Field Webhook

    Trello.webhook.searchField('WEBHOOK_ID', 'FIELD_NAME').then(function (response) {
        console.log('response ', response);
    }).catch(function (error) {
        console.log('error', error);
    });

Update Webhook

    var id = 'WEBHOOK_ID'; // REQUIRED
    var data = {
        displayName: 'ORGANIZATION_DISPLAY_NAME',
        description: 'Webhook descriptions',
        callbackURL: 'https://mycallbackurl.com/',
        idModel: 'MODEL_ID',
        active: false
    };
    Trello.webhook.update(id, data).then(function (response) {
        console.log('response ', response);
    }).catch(function (error) {
        console.log('error', error);
    });

Delete Webhook

    Trello.webhook.del('WEBHOOK_ID').then(function (response) {
        console.log('response ', response);
    }).catch(function (error) {
        console.log('error', error);
    });