Webhook Management
generate_webhook_secret
generate_webhook_secret
Generates a webhook secret from a secure random source.
Arguments
None
Return
Base64-decoded string of the generated webhook secret.
HCK7CWdt83qYfstai9eRlu1Sbw3cZ1uQ1kQYcgofW/Q=
Examples
from datature.nexus.utils import utils
utils.generate_webhook_secret()
create
create
Creates a webhook to a public HTTPs URL.
Arguments
Attribute | Type | Description |
---|---|---|
name | str | Name of the webhook. |
webhook_spec | WebhookSpec | Webhook configuration. |
Return
For security purposes, webhook secrets will NOT be returned in the response body. Please use the
test()
function to validate that our servers can establish a connection with your endpoint URL.
WebhookModel
object containing the metadata of the newly-created webhook with the following structure:
WebhookModel(
id='webhook_f7d8aec2-7e2b-4d2c-a103-c8dd575c29c7',
object='webhook',
project_id='proj_ca5fe71e7592bbcf7705ea36e4f29ed4',
name='aws-lambda',
endpoint='https://lambda-url.ap-southeast-1.on.aws/',
retries=WebhookRetries(
max_retries=3,
max_retry_delay=15000
),
create_date=1723633671620,
update_date=1723736909980
)
Attribute | Type | Description |
---|---|---|
id | str | The webhook ID as a string. |
object | str | Object type of the webhook. |
project_id | str | Identifier of the project associated with the webhook. |
name | str | Name of the webhook. |
endpoint | str | URL endpoint of the webhook. |
retries | WebhookRetries | Retry configuration for the webhook. |
create_date | int | Creation timestamp of the webhook, in milliseconds. |
update_date | int | Last updated timestamp of the webhook, in milliseconds. |
Examples
Create a new webhook with a generated webhook secret:
from datature.nexus import Client
from datature.nexus.utils import utils
project = Client("5aa41e8ba........").get_project("proj_b705a........")
webhook_secret = utils.generate_webhook_secret()
project.batch.webhooks.create(
name="aws-lambda",
webhook_spec={
"endpoint": "https://lambda-url.ap-southeast-1.on.aws/",
"retries": {
"max_retries": 3,
"max_retry_delay": 15000
},
"secret": {
"contents": webhook_secret,
},
}
)
list
list
Lists all created webhooks in the project.
Arguments
Name | Type | Description |
---|---|---|
pagination | dict | A dictionary containing the limit of the number of webhooks to be returned in each page (defaults to 1000), and the page cursor for page selection (defaults to the first page) |
Return
PaginationResponse
object containing a list of WebhookModel
objects with page navigation data, with the following structure:
PaginationResponse(
next_page=None,
prev_page=None,
data=[
WebhookModel(
id='webhook_f7d8aec2-7e2b-4d2c-a103-c8dd575c29c7',
object='webhook',
project_id='proj_ca5fe71e7592bbcf7705ea36e4f29ed4',
name='localhost',
endpoint='https://lambda-url.ap-southeast-1.on.aws/',
retries=WebhookRetries(
max_retries=3,
max_retry_delay=15000
),
create_date=1723633671620,
update_date=1723736909980
)
]
)
Attribute | Type | Description |
---|---|---|
next_page | str | Page ID of the next page. |
prev_page | str | Page ID of the prev page. |
data | List[WebhookModel] | List of webhook metadata. |
Examples
- Default listing of webhooks (shows first 1000 webhooks):
from datature.nexus import Client
project = Client("5aa41e8ba........").get_project("proj_b705a........")
project.batch.webhooks.list()
- View the next page of results:
from datature.nexus import Client
project = Client("5aa41e8ba........").get_project("proj_b705a........")
next_page = project.batch.webhooks.list()["next_page"]
project.batch.webhooks.list({"page": next_page})
- View the previous page of results:
from datature.nexus import Client
project = Client("5aa41e8ba........").get_project("proj_b705a........")
prev_page = project.batch.webhooks.list({
"page": "ZjYzYmJkM2FjN2UxOTA4ZmU0ZjE0Yjk5Mg"}
)["prev_page"]
project.batch.webhooks.list({"page": prev_page})
- List a specific page of webhooks that returns 2 webhooks on that page:
from datature.nexus import Client
project = Client("5aa41e8ba........").get_project("proj_b705a........")
project.batch.webhooks.list({
"limit": 2,
"page": "ZjYzYmJkM2FjN2UxOTA4ZmU0ZjE0Yjk5Mg"
})
get
get
Retrieves a specific webhook by ID.
Arguments
Name | Type | Description |
---|---|---|
webhook_id | str | The webhook ID as a string. |
Return
WebhookModel
object containing the metadata of the retrieved webhook with the following structure:
WebhookModel(
id='webhook_f7d8aec2-7e2b-4d2c-a103-c8dd575c29c7',
object='webhook',
project_id='proj_ca5fe71e7592bbcf7705ea36e4f29ed4',
name='aws-lambda',
endpoint='https://lambda-url.ap-southeast-1.on.aws/',
retries=WebhookRetries(
max_retries=3,
max_retry_delay=15000
),
create_date=1723633671620,
update_date=1723736909980
)
Attribute | Type | Description |
---|---|---|
id | str | The webhook ID as a string. |
object | str | Object type of the webhook. |
project_id | str | Identifier of the project associated with the webhook. |
name | str | Name of the webhook. |
endpoint | str | URL endpoint of the webhook. |
retries | WebhookRetries | Retry configuration for the webhook. |
create_date | int | Creation timestamp of the webhook, in milliseconds. |
update_date | int | Last updated timestamp of the webhook, in milliseconds. |
Examples
Retrieve webhook by webhook ID:
from datature.nexus import Client
project = Client("5aa41e8ba........").get_project("proj_b705a........")
project.batch.webhooks.get("webhook_6aea3395-9a72-4bb5-9ee0-19248c903c56")
update
update
Updates the configuration of a specific webhook. All webhook fields can be updated, with the exception of the webhook secret, which can only be updated through the update_secret()
function.
Arguments
Name | Type | Description |
---|---|---|
webhook_id | str | The webhook ID as a string. |
webhook_spec | str | New webhook configuration. |
Return
WebhookModel
object containing the metadata of the newly-created webhook with the following structure:
WebhookModel(
id='webhook_f7d8aec2-7e2b-4d2c-a103-c8dd575c29c7',
object='webhook',
project_id='proj_ca5fe71e7592bbcf7705ea36e4f29ed4',
name='aws-lambda',
endpoint='https://lambda-url.ap-southeast-1.on.aws/',
retries=WebhookRetries(
max_retries=3,
max_retry_delay=15000
),
create_date=1723633671620,
update_date=1723736909980
)
Attribute | Type | Description |
---|---|---|
id | str | The webhook ID as a string. |
object | str | Object type of the webhook. |
project_id | str | Identifier of the project associated with the webhook. |
name | str | Name of the webhook. |
endpoint | str | URL endpoint of the webhook. |
retries | WebhookRetries | Retry configuration for the webhook. |
create_date | int | Creation timestamp of the webhook, in milliseconds. |
update_date | int | Last updated timestamp of the webhook, in milliseconds. |
Examples
Update the endpoint and retry configuration of an existing webhook:
from datature.nexus import Client
project = Client("5aa41e8ba........").get_project("proj_b705a........")
project.batch.webhooks.update(
webhook_id="webhook_f7d8aec2-7e2b-4d2c-a103-c8dd575c29c7",
webhook_spec={
"endpoint": "https://lambda-url.ap-southeast-1.on.aws/",
"retries": {
"max_retries": 3,
"max_retry_delay": 15000
}
}
)
update_secret
update_secret
Updates the webhook secret of a specific webhook by ID.
Arguments
Name | Type | Description |
---|---|---|
webhook_id | str | The webhook ID as a string. |
secret | str | The new base64-decoded webhook secret. |
Return
For security purposes, webhook secrets will NOT be returned in the response body. Please use the
test()
function to validate that our servers can establish a connection with your endpoint URL.
WebhookModel
object containing the metadata of the newly-created webhook with the following structure:
WebhookModel(
id='webhook_f7d8aec2-7e2b-4d2c-a103-c8dd575c29c7',
object='webhook',
project_id='proj_ca5fe71e7592bbcf7705ea36e4f29ed4',
name='aws-lambda',
endpoint='https://lambda-url.ap-southeast-1.on.aws/',
retries=WebhookRetries(
max_retries=3,
max_retry_delay=15000
),
create_date=1723633671620,
update_date=1723736909980
)
Attribute | Type | Description |
---|---|---|
id | str | The webhook ID as a string. |
object | str | Object type of the webhook. |
project_id | str | Identifier of the project associated with the webhook. |
name | str | Name of the webhook. |
endpoint | str | URL endpoint of the webhook. |
retries | WebhookRetries | Retry configuration for the webhook. |
create_date | int | Creation timestamp of the webhook, in milliseconds. |
update_date | int | Last updated timestamp of the webhook, in milliseconds. |
Examples
Generate a new webhook secret and update an existing webhook:
from datature.nexus import Client
from datature.nexus.utils import utils
project = Client("5aa41e8ba........").get_project("proj_b705a........")
webhook_secret = utils.generate_webhook_secret()
project.batch.webhooks.update_secret(
webhook_id="webhook_f7d8aec2-7e2b-4d2c-a103-c8dd575c29c7",
secret=webhook_secret,
)
test
test
Tests a webhook by sending a sample payload to the endpoint URL.
Arguments
Name | Type | Description |
---|---|---|
webhook_id | str | The webhook ID as a string. |
Return
WebhookTestResponse
object containing details of the webhook test with the following structure:
WebhookTestResponse(
status='Ok',
response_code=204,
latency_ms=648,
attempt_count=1,
body=None,
reason=None
)
Attribute | Type | Description |
---|---|---|
status | str | Status of the webhook test |
response_code | int | Response code of the webhook test. |
latency_ms | int | Latency of the webhook test, in milliseconds. |
attempt_count | int | Number of attempts made to test the webhook for a successful response. |
body | Optional[str] | Body of the webhook test response, if any. |
reason | Optional[str] | Reason for the error in the webhook test response, if any. |
Examples
Send a sample payload to the specified webhook:
from datature.nexus import Client
project = Client("5aa41e8ba........").get_project("proj_b705a........")
project.batch.webhooks.test("webhook_f7d8aec2-7e2b-4d2c-a103-c8dd575c29c7")
delete
delete
Deletes a specific webhook by ID.
Arguments
Name | Type | Description |
---|---|---|
webhook_id | str | The webhook ID as a string. |
Return
DeleteResponse
object that describe the deletion status of the webhook, with the following structure:
DeleteResponse(
id='webhook_f7d8aec2-7e2b-4d2c-a103-c8dd575c29c7',
deleted=True
)
Attribute | Type | Description |
---|---|---|
id | str | The webhook ID as a string. |
deleted | bool | Whether the webhook has been successfully deleted or not. |
Examples
Delete a specified webhook:
from datature.nexus import Client
project = Client("5aa41e8ba........").get_project("proj_b705a........")
project.batch.webhooks.delete("webhook_f7d8aec2-7e2b-4d2c-a103-c8dd575c29c7")
Updated about 2 months ago