API reference

Webhooks

Register one endpoint per account to receive pushed notices such as a revoked grant. Read the Webhooks page for what the signature header can and cannot show you.

DELETE /v1/webhooks

Remove the registration

Removes the endpoint; queued deliveries to it are dropped at the next drain.

Auth
session cookie or API key
Capability
webhooks
Success
HTTP 200

Parameters

None.

Request body

None.

Example request

curl

curl -sS -X DELETE "https://api.afaprotocol.com/v1/webhooks" \
  -H "X-API-Key: afa-beta-EXAMPLE-e4qs"

Python

import requests

API = "https://api.afaprotocol.com"
headers = {"X-API-Key": "afa-beta-EXAMPLE-e4qs"}

r = requests.delete(f"{API}/v1/webhooks", headers=headers, timeout=30)
r.raise_for_status()
print(r.json())

Example response

HTTP 200
{
  "deleted": true,
  "user_id": "2f6e1a0c-9b4d-4e8a-8c31-5d7f0a2b9c14"
}

Errors

StatusCodeMeaning
401missing_token / invalid_or_expired_api_keyNo credential, an expired session, or a revoked or expired key.
403scope_missingA key limited by scopes lacks webhooks; the body names it.

What would show this is false

Delete twice: the second answers deleted false. The first removed it and the second found nothing.

GET /v1/webhooks

Current registration

Shows whether an endpoint is registered and which URL.

Auth
session cookie or API key
Capability
webhooks
Success
HTTP 200

Parameters

None.

Request body

None.

Example request

curl

curl -sS -X GET "https://api.afaprotocol.com/v1/webhooks" \
  -H "X-API-Key: afa-beta-EXAMPLE-e4qs"

Python

import requests

API = "https://api.afaprotocol.com"
headers = {"X-API-Key": "afa-beta-EXAMPLE-e4qs"}

r = requests.get(f"{API}/v1/webhooks", headers=headers, timeout=30)
r.raise_for_status()
print(r.json())

Example response

HTTP 200
{
  "configured": true,
  "url": "https://hooks.example.com/afa/7f3a1c"
}

Errors

StatusCodeMeaning
401missing_token / invalid_or_expired_api_keyNo credential, an expired session, or a revoked or expired key.
403scope_missingA key limited by scopes lacks webhooks; the body names it.

What would show this is false

The response carries no secret. Until it does, the X-AFA-Signature header cannot be recomputed on your side; the Webhooks page says what to do instead.

PUT /v1/webhooks

Register the endpoint

Registers or replaces the one URL that receives pushed notices for this account.

Auth
session cookie or API key
Capability
webhooks
Success
HTTP 200

Parameters

None.

Request body

url string required
No description in the schema.

Example request

curl

curl -sS -X PUT "https://api.afaprotocol.com/v1/webhooks" \
  -H "X-API-Key: afa-beta-EXAMPLE-e4qs" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://hooks.example.com/afa/7f3a1c"
}'

Python

import requests

API = "https://api.afaprotocol.com"
headers = {"X-API-Key": "afa-beta-EXAMPLE-e4qs"}
payload = {
    "url": "https://hooks.example.com/afa/7f3a1c"
}

r = requests.put(f"{API}/v1/webhooks", headers=headers, json=payload, timeout=30)
r.raise_for_status()
print(r.json())

Example response

HTTP 200
{
  "configured": true,
  "url": "https://hooks.example.com/afa/7f3a1c",
  "user_id": "2f6e1a0c-9b4d-4e8a-8c31-5d7f0a2b9c14"
}

Errors

StatusCodeMeaning
401missing_token / invalid_or_expired_api_keyNo credential, an expired session, or a revoked or expired key.
403scope_missingA key limited by scopes lacks webhooks; the body names it.
422validation errorA required field is missing or a value has the wrong type.
422webhook url must be an absolute http(s) URLRefused and not stored, so a dead registration can never exist.

What would show this is false

Register ftp://example.com: 422, and GET /v1/webhooks still shows the previous registration.