GoCardlessDeveloper Docs
Create a sandbox account

Webhook

View as Markdown

Basic description of a webhook

List webhooks#

GET/webhooks

Returns a cursor-paginated list of your webhooks.

GET https://api.gocardless.com/webhooks/WB123?successful=true HTTP/1.1
@client.webhooks.list

@client.webhooks.list(params: { successful: true })
client.webhooks.list().records

client.webhooks.list(params={"successful": True}).records
const webhooks = await client.webhooks.list();

// List all webhooks past a certain date.
const filteredWebhooks = await client.webhooks.list({
  created_at: {
    gt: "2020-01-01T17:01:06.000Z"
  }
});
$client->webhooks()->list();

$client->webhooks()->list([
  "params" => ["successful" => True]
]);
for (com.gocardless.resources.Webhook webhook : client.webhooks().all().withSuccessful(true).execute()) {
  System.out.println(webhook.getId());
}
webhookListParams := gocardless.WebhookListParams{
  CreatedAt: &gocardless.WebhookListParamsCreatedAt{
    Gt: "2020-01-01T17:01:06.000Z",
  },
}

webhookListResult, err := client.Webhooks.List(ctx, webhookListParams)
for _, webhook := range webhookListResult.Webhooks {
    fmt.Println(webhook.Id)
}
var webhookRequest = new GoCardless.Services.WebhookListRequest()
{
    Successful = true
};

var webhookListResponse = client.Webhooks.All(webhookRequest);
foreach (GoCardless.Resources.Webhook webhook in webhookListResponse)
{
    Console.WriteLine(webhook.Id);
}
Responsehttp
HTTP/1.1 200 OK
Content-Type: application/json
{
  "meta": {
    "cursors": {
      "after": null,
      "before": null
    },
    "limit": 5
  },
  "webhooks": [{
      "created_at": "2018-03-12T15:13:37.416Z",
      "id": "WB123",
      "is_test": true,
      "request_body": "{\"events\":[{\"id\":\"EV123\",\"created_at\":\"2018-03-12T15:13:37.158Z\",\"resource_type\":\"payments\",\"action\":\"created\",\"links\":{\"payment\":\"PM123\"},\"details\":{\"origin\":\"api\",\"cause\":\"payment_created\",\"description\":\"Payment created via the API.\"},\"metadata\":{}}]}",
      "request_headers": {
        "Content-Type": "application/json",
        "Origin": "https://api.gocardless.com",
        "User-Agent": "gocardless-webhook-service/1.1",
        "Webhook-Signature": "e4d043149b4cc27435d05ea275a09de2f810e45bed5448fd6a0a742a3846b365"
      },
      "response_body": "ok",
      "response_body_truncated": false,
      "response_code": 200,
      "response_headers": {
        "content-type": "text/html; charset=utf-8",
        "date": "Mon, 12 Mar 2018 15:13:37 GMT"
      },
      "response_headers_content_truncated": false,
      "response_headers_count_truncated": false,
      "successful": true,
      "url": "https://example.com/webhook_handler"
  }]
}
Response 200

Successful response

webhooksarray
13 properties
idstring

Unique identifier, beginning with "WB".

created_atstring

Fixed timestamp, recording when this resource was created.

urlstring

URL the webhook was POST-ed to

request_headersobject

The request headers sent with the webhook

request_bodystring

The body of the request sent to the webhook URL

response_codeinteger

The response code from the webhook request

response_bodystring

The body of the response from the webhook URL

response_body_truncatedboolean

Boolean value indicating the webhook response body was truncated

response_headersobject

The headers sent with the response from the webhook URL

response_headers_content_truncatedboolean

Boolean indicating the content of response headers was truncated

response_headers_count_truncatedboolean

Boolean indicating the number of response headers was truncated

is_testboolean

Boolean value showing whether this was a demo webhook for testing

successfulboolean

Boolean indicating whether the request was successful or failed

metaobject
2 properties
limitinteger
cursorsobject
2 properties
beforestring

Cursor pointing to the end of the desired set.

afterstring

Cursor pointing to the start of the desired set.

Errors 400401404422500
400

Bad Request

401

Unauthorised

404

Not found

422

Validation Error

500

Internal Error

Error Body
codeinteger
documentation_urlstring
errorsarray
2 properties
reasonstring
messagestring
messagestring
request_idstring
typestring
metadataobject
linksobject

Get a single webhook#

GET/webhooks/{webhook_id}

Retrieves the details of an existing webhook.

Path Parameters

NameTypeDescription
webhook_idrequiredstring

The webhook id

GET https://api.gocardless.com/webhooks/WB123 HTTP/1.1
@client.webhooks.get("WB123")
client.webhooks.get("WB123")
const webhook = await client.webhooks.find("WB123");
$client->webhooks()->get("WB123");
com.gocardless.resources.Webhook webhook = client.webhooks().get("WB123").execute();
webhook, err := client.Webhooks.Get(ctx, "WB123")
var webhookResponse = await client.Webhooks.GetAsync("WB123");
GoCardless.Resources.Webhook webhook = webhookResponse.Webhook;
Responsehttp
HTTP/1.1 200 OK
Content-Type: application/json
{
  "webhooks": {
      "created_at": "2018-03-12T15:13:37.416Z",
      "id": "WB123",
      "is_test": true,
      "request_body": "{\"events\":[{\"id\":\"EV123\",\"created_at\":\"2018-03-12T15:13:37.158Z\",\"resource_type\":\"payments\",\"action\":\"created\",\"links\":{\"payment\":\"PM123\"},\"details\":{\"origin\":\"api\",\"cause\":\"payment_created\",\"description\":\"Payment created via the API.\"},\"metadata\":{}}]}",
      "request_headers": {
        "Content-Type": "application/json",
        "Origin": "https://api.gocardless.com",
        "User-Agent": "gocardless-webhook-service/1.1",
        "Webhook-Signature": "e4d043149b4cc27435d05ea275a09de2f810e45bed5448fd6a0a742a3846b365"
      },
      "response_body": "ok",
      "response_body_truncated": false,
      "response_code": 200,
      "response_headers": {
        "content-type": "text/html; charset=utf-8",
        "date": "Mon, 12 Mar 2018 15:13:37 GMT"
      },
      "response_headers_content_truncated": false,
      "response_headers_count_truncated": false,
      "successful": true,
      "url": "https://example.com/webhook_handler"
  }
}
Response 200

Successful response

webhooksobject
13 properties
idstring

Unique identifier, beginning with "WB".

created_atstring

Fixed timestamp, recording when this resource was created.

urlstring

URL the webhook was POST-ed to

request_headersobject

The request headers sent with the webhook

request_bodystring

The body of the request sent to the webhook URL

response_codeinteger

The response code from the webhook request

response_bodystring

The body of the response from the webhook URL

response_body_truncatedboolean

Boolean value indicating the webhook response body was truncated

response_headersobject

The headers sent with the response from the webhook URL

response_headers_content_truncatedboolean

Boolean indicating the content of response headers was truncated

response_headers_count_truncatedboolean

Boolean indicating the number of response headers was truncated

is_testboolean

Boolean value showing whether this was a demo webhook for testing

successfulboolean

Boolean indicating whether the request was successful or failed

Errors 400401404422500
400

Bad Request

401

Unauthorised

404

Not found

422

Validation Error

500

Internal Error

Error Body
codeinteger
documentation_urlstring
errorsarray
2 properties
reasonstring
messagestring
messagestring
request_idstring
typestring
metadataobject
linksobject

Retry a webhook#

POST/webhooks/{webhook_id}/actions/retry

Requests for a previous webhook to be sent again

Path Parameters

NameTypeDescription
webhook_idrequiredstring

The webhook id

POST https://api.gocardless.com/webhooks/WB123/actions/retry HTTP/1.1
@client.webhooks.retry("WB123")
client.webhooks.retry("WB123")
const webhookResponse = await client.webhooks.retry("WB123");
$client->webhooks()->retry("WB123");
client.webhooks().retry("WB123").execute();
webhook, err := client.Webhooks.Retry(ctx, "WB123")
var webhookResponse = await client.Webhooks.RetryAsync("WB123");
Responsehttp
HTTP/1.1 200 OK
Content-Type: application/json
{
  "webhooks": {
      "created_at": "2018-03-12T15:13:37.416Z",
      "id": "WB123",
      "is_test": true,
      "request_body": "{\"events\":[{\"id\":\"EV123\",\"created_at\":\"2018-03-12T15:13:37.158Z\",\"resource_type\":\"payments\",\"action\":\"created\",\"links\":{\"payment\":\"PM123\"},\"details\":{\"origin\":\"api\",\"cause\":\"payment_created\",\"description\":\"Payment created via the API.\"},\"metadata\":{}}]}",
      "request_headers": {
        "Content-Type": "application/json",
        "Origin": "https://api.gocardless.com",
        "User-Agent": "gocardless-webhook-service/1.1",
        "Webhook-Signature": "e4d043149b4cc27435d05ea275a09de2f810e45bed5448fd6a0a742a3846b365"
      },
      "response_body": "ok",
      "response_body_truncated": false,
      "response_code": 200,
      "response_headers": {
        "content-type": "text/html; charset=utf-8",
        "date": "Mon, 12 Mar 2018 15:13:37 GMT"
      },
      "response_headers_content_truncated": false,
      "response_headers_count_truncated": false,
      "successful": true,
      "url": "https://example.com/webhook_handler"
  }
}
Response 200

Action completed successfully

webhooksobject
13 properties
idstring

Unique identifier, beginning with "WB".

created_atstring

Fixed timestamp, recording when this resource was created.

urlstring

URL the webhook was POST-ed to

request_headersobject

The request headers sent with the webhook

request_bodystring

The body of the request sent to the webhook URL

response_codeinteger

The response code from the webhook request

response_bodystring

The body of the response from the webhook URL

response_body_truncatedboolean

Boolean value indicating the webhook response body was truncated

response_headersobject

The headers sent with the response from the webhook URL

response_headers_content_truncatedboolean

Boolean indicating the content of response headers was truncated

response_headers_count_truncatedboolean

Boolean indicating the number of response headers was truncated

is_testboolean

Boolean value showing whether this was a demo webhook for testing

successfulboolean

Boolean indicating whether the request was successful or failed

Errors 400401404422500
400

Bad Request

401

Unauthorised

404

Not found

422

Validation Error

500

Internal Error

Error Body
codeinteger
documentation_urlstring
errorsarray
2 properties
reasonstring
messagestring
messagestring
request_idstring
typestring
metadataobject
linksobject