interface WebHooks {
    active: boolean;
    filters?: WebhookFilter[];
    headers: WebhookHeader[];
    httpBasicPassword?: string;
    httpBasicUsername?: string;
    name: string;
    sys: BasicMetaSysProps & {
        space: SysLink;
    };
    topics: string[];
    transformation?: WebhookTransformation;
    url: string;
    delete(): Promise<void>;
    getCall(id: string): Promise<WebhookCallDetailsProps>;
    getCalls(): Promise<CollectionProp<{
        errors: any[];
        eventType: string;
        requestAt: string;
        responseAt: string;
        statusCode: number;
        sys: {
            createdAt: string;
            createdBy?: SysLink;
            id: string;
            type: string;
        };
        url: string;
    }>>;
    getHealth(): Promise<WebhookHealthProps>;
    toPlainObject(): WebhookProps;
    update(): Promise<WebHooks>;
}

Hierarchy (view full)

Properties

active: boolean

Whether the Webhook is active. If set to false, no calls will be made

filters?: WebhookFilter[]

Webhook filters

headers: WebhookHeader[]

Headers that should be appended to the webhook request

httpBasicPassword?: string

Password for basic http auth

httpBasicUsername?: string

Username for basic http auth

name: string

Webhook name

sys: BasicMetaSysProps & {
    space: SysLink;
}

System metadata

topics: string[]

Topics the webhook wants to subscribe to

transformation?: WebhookTransformation

Transformation to apply

url: string

Webhook url

Methods

  • Deletes this object on the server.

    Returns Promise<void>

    Promise for the deletion. It contains no data, but the Promise error case should be handled.

    const contentful = require('contentful-management')

    const client = contentful.createClient({
    accessToken: '<content_management_api_key>'
    })

    client.getSpace('<space_id>')
    .then((space) => space.getWebhook('<webhook_id>'))
    .then((webhook) => webhook.delete())
    .then((webhook) => console.log(`webhook ${webhook.sys.id} updated.`))
    .catch(console.error)
  • Returns Promise<CollectionProp<{
        errors: any[];
        eventType: string;
        requestAt: string;
        responseAt: string;
        statusCode: number;
        sys: {
            createdAt: string;
            createdBy?: SysLink;
            id: string;
            type: string;
        };
        url: string;
    }>>

    Promise for list of calls

    const contentful = require('contentful-management')

    const client = contentful.createClient({
    accessToken: '<content_management_api_key>'
    })

    client.getSpace('<space_id>')
    .then((space) => space.getWebhook('<webhook_id>'))
    .then((webhook) => webhook.getCalls())
    .then((response) => console.log(response.items)) // webhook calls
    .catch(console.error)
  • Sends an update to the server with any changes made to the object's properties

    Returns Promise<WebHooks>

    Object returned from the server with updated changes.

    const contentful = require('contentful-management')

    const client = contentful.createClient({
    accessToken: '<content_management_api_key>'
    })

    client.getSpace('<space_id>')
    .then((space) => space.getWebhook('<webhook_id>'))
    .then((webhook) => {
    webhook.name = 'new webhook name'
    return webhook.update()
    })
    .then((webhook) => console.log(`webhook ${webhook.sys.id} updated.`))
    .catch(console.error)