Provides API endpoints related to api/webhooks
Summary
Functions
Create webhook
Delete webhook
Get webhook
Get list of webhooks
Test webhook
Update webhook
Functions
@spec create( body :: map() | ApifyClient.Schemas.CreateWebhookRequest.t(), opts :: keyword() ) :: {:ok, ApifyClient.Schemas.WebhookResource.t()} | {:error, ApifyClient.Error.t()}
Create webhook
Creates a new webhook with settings provided by the webhook object passed as JSON in the payload. The response is the created webhook object.
To avoid duplicating a webhook, use the idempotencyKey parameter in the
request body.
Multiple calls to create a webhook with the same idempotencyKey will only
create the webhook with the first call and return the existing webhook on
subsequent calls.
Idempotency keys must be unique, so use a UUID or another random string with
enough entropy.
To assign the new webhook to an Actor or task, the request body must contain
requestUrl, eventTypes, and condition properties.
requestUrlis the webhook's target URL, to which data is sent as a POST request with a JSON payload.eventTypesis a list of events that will trigger the webhook, e.g. when the Actor run succeeds.conditionshould be an object containing the ID of the Actor or task to which the webhook will be assigned.payloadTemplateis a JSON-like string, whose syntax is extended with the use of variables.headersTemplateis a JSON-like string, whose syntax is extended with the use of variables. Following values will be re-written to defaults: "host", "Content-Type", "X-Apify-Webhook", "X-Apify-Webhook-Dispatch-Id", "X-Apify-Request-Origin"descriptionis an optional string.shouldInterpolateStringsis a boolean indicating whether to interpolate variables contained inside strings in thepayloadTemplate
"isAdHoc" : false,
"requestUrl" : "https://example.com",
"eventTypes" : [
"ACTOR.RUN.SUCCEEDED",
"ACTOR.RUN.ABORTED"
],
"condition" : {
"actorId": "5sTMwDQywwsLzKRRh",
"actorTaskId" : "W9bs9JE9v7wprjAnJ"
},
"payloadTemplate": "",
"headersTemplate": "",
"description": "my awesome webhook",
"shouldInterpolateStrings": false,Important: The request must specify the Content-Type: application/json
HTTP header.
Request Body
Content Types: application/json
@spec delete(webhook_id :: String.t(), opts :: keyword()) :: :ok | {:error, ApifyClient.Error.t()}
Delete webhook
Deletes a webhook.
@spec get(webhook_id :: String.t(), opts :: keyword()) :: {:ok, ApifyClient.Schemas.WebhookResource.t()} | {:error, ApifyClient.Error.t()}
Get webhook
Gets webhook object with all details.
@spec list(opts :: keyword()) :: {:ok, ApifyClient.Schemas.ListOfWebhooks.t()} | {:error, ApifyClient.Error.t()}
Get list of webhooks
Gets the list of webhooks that the user created.
The endpoint supports pagination using the limit and offset parameters
and it will not return more than 1000 records.
By default, the records are sorted by the createdAt field in ascending
order. To sort the records in descending order, use the desc=1
parameter.
Options
offset: Number of items that should be skipped at the start. The default value is0.limit: Maximum number of items to return. The default value as well as the maximum is1000.desc: Iftrueor1then the objects are sorted by thecreatedAtfield in descending order. By default, they are sorted in ascending order.
@spec test(webhook_id :: String.t(), opts :: keyword()) :: {:ok, ApifyClient.Schemas.WebhookDispatch.t()} | {:error, ApifyClient.Error.t()}
Test webhook
Tests a webhook. Creates a webhook dispatch with a dummy payload.
@spec update( webhook_id :: String.t(), body :: map() | ApifyClient.Schemas.UpdateWebhookRequest.t(), opts :: keyword() ) :: {:ok, ApifyClient.Schemas.WebhookResource.t()} | {:error, ApifyClient.Error.t()}
Update webhook
Updates a webhook using values specified by a webhook object passed as JSON in the POST payload. If the object does not define a specific property, its value will not be updated.
The response is the full webhook object as returned by the Get webhook endpoint.
The request needs to specify the Content-Type: application/json HTTP
header!
When providing your API authentication token, we recommend using the
request's Authorization header, rather than the URL.
For details, see Authentication.
Request Body
Content Types: application/json