跳到主要内容
Reincubate

Webhook configs

发布于 2019年6月26日· 更新于 2023年1月23日

Cover image for: Webhook configs

The webhook config resource is used by the API to send events to your webhook receiver.

An organisation can have a default webook config which is used by all keys within that organisation that don't specify a webhook config of their own.

Attributes

nametypedescription
idwebhook config IDResource identifier.
resourcestring, always webhook_configResource type specifier.
organisationorganisation IDThe organisation the resource belongs to.
urlstringThe url to target when sending events.
secretstringThe shared secret used to verify event signatures.
statestringOne of: new, valid, invalid, deactivated.
date_createddatetimeWhen the resource was created.

Secret

When a webhook config is created, a secret will be generated alongside it that will be used to sign events sent by the API. It is highly recommended that you implement your webhook receiver to verify the signature of incoming events using this secret. For more details on the signature verification procedure see the webhook configuration docs.

States

  • new has just been created or recently updated but not yet tested.
  • valid has passed validation and is ready to be used. An organisation must have at least one webhook config in this state in order to be useable.
  • invalid has failed the validation test. Must be updated or retested.
  • deactivated has been turned off by the owning organisation.

Create POST /configs/webhook

This action will create a webhook_config.test task in order to validate the endpoint details. If the webhook receiver is not yet setup, this test will likely fail and set the config to the invalid state. However, the config can always be re-tested using the test action.

Parameters

nametypedescription
urlrequiredThe URL of your webhook receiver.

Using cURL

curl https://ricloud-api.reincubate.com/configs/webhook \
  -X POST \
  -H 'Authorization: Token <your key_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "url": "https://www.mywebhook.com/webhooks/"
}'

Using ricloud-py

import ricloud

webhook_config = ricloud.WebhookConfig.create(url='https://www.mywebhook.com/webhooks/')

Retrieve GET /configs/webhook/{webhook_config ID}

Using cURL

curl https://ricloud-api.reincubate.com/configs/webhook/<webhook_config ID> \
  -H 'Authorization: Token <your key_token>'

Using ricloud-py

import ricloud

webhook_config = ricloud.WebhookConfig.retrieve(<webhook_config ID>)

List GET /configs/webhook

Webhook configs in the deactivated state are hidden by default and can only be listed by explicit filtering.

Parameters

nametypedescription
statestringFilter webhook configs by their state.
date_createddatetime filterFilter by resource creation date.

Update POST /configs/webhook/{webhook_config ID}

This action will create a webhook_confg.test task in the background to validate any changes made to the config.

The state attribute can only be changed to deactivated in the case you are essentially retiring a config.

Parameters

nametypedescription
urlstringUpdate the URL.
statestringOnly to new or deactivated.

Using cURL

curl https://ricloud-api.reincubate.com/configs/webhook/<webhook_config ID> \
  -X POST \
  -H 'Authorization: Token <your key_token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://www.myupdatedwebhook.com/webhooks/",
}'

Using ricloud-py

import ricloud

webhook_config = ricloud.WebhookConfig.update_with_id(
  <webhook_config ID>,
  url='https://www.myupdatedwebhook.com/webhooks/'
)

# OR

webhook_config = ricloud.WebhookConfig.retrieve(<webhook_config ID>)

webhook_config.update(url='https://www.myupdatedwebhook.com/webhooks/')

Test POST /configs/webhook/{webhook_config ID}/test

This action creates a webhook_config.test task which sends a test event using the specified configuration. The outcome of the test will update the state attribute of the webook configuration accordingly.

Using cURL

curl https://ricloud-api.reincubate.com/configs/webhook/<webhook_config ID>/test \
  -H 'Authorization: Token <your key_token>'

Using ricloud-py

import ricloud

test_task = ricloud.WebhookConfig.test_with_id(<webhook_config ID>)

# OR

webhook_config = ricloud.WebhookConfig.retrieve(<webhook_config ID>)

test_task = webhook_config.test()

相关文章

需要帮助吗?

我们会尽力在一个工作日内回复所有消息。

support@reincubate.com
帮助