Activate a resthook subscription
curl --request POST \
--url https://{region}.affinda.com/v2/resthook_subscriptions/activate \
--header 'Authorization: Bearer <token>' \
--header 'X-Hook-Secret: <x-hook-secret>'import requests
url = "https://{region}.affinda.com/v2/resthook_subscriptions/activate"
headers = {
"X-Hook-Secret": "<x-hook-secret>",
"Authorization": "Bearer <token>"
}
response = requests.post(url, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Hook-Secret': '<x-hook-secret>', Authorization: 'Bearer <token>'}
};
fetch('https://{region}.affinda.com/v2/resthook_subscriptions/activate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": 2,
"event": "document.parse.succeeded",
"targetUrl": "https://my-site.com/receive",
"active": true,
"autoDeactivated": true,
"autoDeactivateReason": "Resthook fails after 10 retries. The last error received was: 500 - Internal server error.",
"version": "v3"
}{
"type": "validation_error",
"errors": [
{
"attr": "non_field_errors",
"code": "unique",
"detail": "This index name has already been used"
}
]
}{
"type": "validation_error",
"errors": [
{
"attr": "non_field_errors",
"code": "unique",
"detail": "This index name has already been used"
}
]
}{
"type": "validation_error",
"errors": [
{
"attr": "non_field_errors",
"code": "unique",
"detail": "This index name has already been used"
}
]
}Webhook API
Activate a resthook subscription
deprecated
After creating a subscription, we’ll send a POST request to your target URL with a X-Hook-Secret header.
You should response to this with a 200 status code, and use the value of the X-Hook-Secret header that you received to activate the subscription using this endpoint.
POST
/
v2
/
resthook_subscriptions
/
activate
Activate a resthook subscription
curl --request POST \
--url https://{region}.affinda.com/v2/resthook_subscriptions/activate \
--header 'Authorization: Bearer <token>' \
--header 'X-Hook-Secret: <x-hook-secret>'import requests
url = "https://{region}.affinda.com/v2/resthook_subscriptions/activate"
headers = {
"X-Hook-Secret": "<x-hook-secret>",
"Authorization": "Bearer <token>"
}
response = requests.post(url, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Hook-Secret': '<x-hook-secret>', Authorization: 'Bearer <token>'}
};
fetch('https://{region}.affinda.com/v2/resthook_subscriptions/activate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": 2,
"event": "document.parse.succeeded",
"targetUrl": "https://my-site.com/receive",
"active": true,
"autoDeactivated": true,
"autoDeactivateReason": "Resthook fails after 10 retries. The last error received was: 500 - Internal server error.",
"version": "v3"
}{
"type": "validation_error",
"errors": [
{
"attr": "non_field_errors",
"code": "unique",
"detail": "This index name has already been used"
}
]
}{
"type": "validation_error",
"errors": [
{
"attr": "non_field_errors",
"code": "unique",
"detail": "This index name has already been used"
}
]
}{
"type": "validation_error",
"errors": [
{
"attr": "non_field_errors",
"code": "unique",
"detail": "This index name has already been used"
}
]
}Authorizations
Basic authentication using an API key, e.g. {Authorization: Bearer 75z0bb4fbdf97b7e4111ff6c0015471094155f91}.
You can find your API key within the Settings page of the Affinda web app. You can obtain an API key by signing up for a free trial.
Headers
Response
Successfully activated a resthook subscription.
The event name to subscribe to.
Available options:
resume.parse.succeeded, resume.parse.failed, resume.parse.completed, invoice.parse.succeeded, invoice.parse.failed, invoice.parse.completed, invoice.validate.completed, document.parse.succeeded, document.parse.failed, document.parse.completed, document.validate.completed, document.classify.succeeded, document.classify.failed, document.classify.completed, document.rejected, annotation.validated, submission.completed Example:
"document.parse.succeeded"

