Add a webhook endpoint
/v1/webhook-endpoints
Platforms and independent practices can register up to 16 public HTTPS endpoints per mode. An API key acts only for its own organization and mode. Every event goes to every endpoint. The signing secret is returned by creation and its idempotent replay for 24 hours.
Request example
Replace example values with your Test data. Check the field rules below before you send a request.
{
"url": "https://example.com/affinity/events"
}
curl -X POST 'https://api.affinityrx.com/v1/webhook-endpoints' \
-H "Authorization: Bearer $AFFINITY_API_KEY" \
-H 'Affinity-Version: 2026-11-01' \
-H 'Idempotency-Key: <Idempotency-Key>' \
-H 'Content-Type: application/json' \
--data @request.json
Response example
These examples show the body structure. Values can differ. Select a status code to see its response.
{
"createdAt": "2026-10-28T15:04:05.000Z",
"updatedAt": "2026-10-28T15:04:05.000Z",
"mode": "test",
"id": "whe_01j2y8m6jcc9tt24af5pw9x1bc",
"url": "https://example.com/affinity/events",
"secret": "<string>"
}
{
"code": "<string>",
"detail": "<string>",
"title": "<string>",
"type": "<string>",
"issues": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>",
"path": [
"<string>"
]
}
],
"instance": "<string>",
"requestId": "<string>",
"status": 400,
"traceId": "<string>"
}
{
"code": "<string>",
"detail": "<string>",
"title": "<string>",
"type": "<string>",
"issues": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>",
"path": [
"<string>"
]
}
],
"instance": "<string>",
"requestId": "<string>",
"status": 401,
"traceId": "<string>"
}
{
"code": "<string>",
"detail": "<string>",
"title": "<string>",
"type": "<string>",
"issues": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>",
"path": [
"<string>"
]
}
],
"instance": "<string>",
"requestId": "<string>",
"status": 403,
"traceId": "<string>"
}
{
"code": "<string>",
"detail": "<string>",
"title": "<string>",
"type": "<string>",
"issues": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>",
"path": [
"<string>"
]
}
],
"instance": "<string>",
"requestId": "<string>",
"status": 404,
"traceId": "<string>"
}
{
"code": "<string>",
"detail": "<string>",
"title": "<string>",
"type": "<string>",
"issues": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>",
"path": [
"<string>"
]
}
],
"instance": "<string>",
"requestId": "<string>",
"status": 409,
"traceId": "<string>",
"data": {
"orderId": "ord_01j2y8m6jcc9tt24af5pw9x1bc",
"practiceId": "prac_01j2y8m6jcc9tt24af5pw9x1bc"
}
}
{
"code": "<string>",
"detail": "<string>",
"title": "<string>",
"type": "<string>",
"issues": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>",
"path": [
"<string>"
]
}
],
"instance": "<string>",
"requestId": "<string>",
"status": 413,
"traceId": "<string>"
}
{
"code": "unsupported_media_type",
"detail": "<string>",
"title": "<string>",
"type": "<string>",
"instance": "<string>",
"requestId": "<string>",
"status": 415,
"traceId": "<string>"
}
{
"code": "<string>",
"detail": "<string>",
"title": "<string>",
"type": "<string>",
"issues": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>",
"path": [
"<string>"
]
}
],
"instance": "<string>",
"requestId": "<string>",
"status": 422,
"traceId": "<string>"
}
{
"code": "<string>",
"detail": "<string>",
"title": "<string>",
"type": "<string>",
"issues": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>",
"path": [
"<string>"
]
}
],
"instance": "<string>",
"requestId": "<string>",
"status": 429,
"traceId": "<string>",
"data": {
"retryAfterSeconds": 1
}
}
{
"code": "<string>",
"detail": "<string>",
"title": "<string>",
"type": "<string>",
"issues": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>",
"path": [
"<string>"
]
}
],
"instance": "<string>",
"requestId": "<string>",
"status": 500,
"traceId": "<string>"
}
{
"code": "<string>",
"detail": "<string>",
"title": "<string>",
"type": "<string>",
"issues": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>",
"path": [
"<string>"
]
}
],
"instance": "<string>",
"requestId": "<string>",
"status": 503,
"traceId": "<string>"
}
Implementation specification
Use these field types and limits to build your integration. Download the OpenAPI document for the complete contract.
Headers
AuthorizationstringFor API key authentication, send Authorization: Bearer <key> with an active API key.
Content-TypestringrequiredSend the JSON body with Content-Type: application/json.
Idempotency-Key
string
required
A unique key per operation, 1 to 255 printable ASCII characters without spaces. Retry the same key and body to avoid repeating the action. The replay response depends on the operation. See https://docs.affinityrx.com/guides/#retry-safely.
Pattern: ^[\x21-\x7e]{1,255}$
Affinity-Version
string
required
The dated API version this request is written against.
Pin requests to 2026-11-01.
Allowed: "2026-11-01"
Default: "2026-11-01"
Request body specification application/json
Send the JSON body with Content-Type: application/json.
url
string
required
The public HTTPS URL that receives webhook events.
Format: uri
Minimum length: 8
Maximum length: 2048
Response specifications
200 OK
application/json
createdAt
string
required
When the record was created.
Format: date-time
updatedAt
string
required
When the record was last updated.
Format: date-time
mode
string
required
The Test or Live mode of this record.
Known values: "test", "live"
id
string
required
The public record identifier.
Pattern: ^whe_[0-7][0-9a-hjkmnp-tv-z]{25}$
url
string
required
The public HTTPS URL that receives webhook events.
Format: uri
secret
string
required
The signing secret, returned on creation and its idempotent replay for 24 hours.
400 Bad Request
application/problem+json
Problem
code
string
required
A stable code for the problem. Branch on it, not on detail.
detail
string
required
What went wrong and what to do, for a person to read.
title
string
required
A short summary of the problem's type.
type
string
required
A URI that names the problem's type.
issues
object[]
One entry for each field that the request got wrong, when the problem is about fields.
Show issues fields
Array items · object
code
string
required
A stable code for this field's problem.
field
string
required
The field as one string, such as patient.address.state or prescriptions[0].quantity.
message
string
required
What is wrong with the field and what to send, for a person to read.
path
string | integer[]
required
The field as a list of property names and array indexes.
Show path fields
Array items · string | integer
string | integer
instance
string
required
The path of the request.
requestId
string
required
Identifies the request, as its X-Request-Id header does. Send it when you report a problem.
status
integer
required
The HTTP status code of the response.
traceId
string
The request trace ID.
401 Unauthorized
application/problem+json
Problem
code
string
required
A stable code for the problem. Branch on it, not on detail.
detail
string
required
What went wrong and what to do, for a person to read.
title
string
required
A short summary of the problem's type.
type
string
required
A URI that names the problem's type.
issues
object[]
One entry for each field that the request got wrong, when the problem is about fields.
Show issues fields
Array items · object
code
string
required
A stable code for this field's problem.
field
string
required
The field as one string, such as patient.address.state or prescriptions[0].quantity.
message
string
required
What is wrong with the field and what to send, for a person to read.
path
string | integer[]
required
The field as a list of property names and array indexes.
Show path fields
Array items · string | integer
string | integer
instance
string
required
The path of the request.
requestId
string
required
Identifies the request, as its X-Request-Id header does. Send it when you report a problem.
status
integer
required
The HTTP status code of the response.
traceId
string
The request trace ID.
403 Forbidden
application/problem+json
Problem
code
string
required
A stable code for the problem. Branch on it, not on detail.
detail
string
required
What went wrong and what to do, for a person to read.
title
string
required
A short summary of the problem's type.
type
string
required
A URI that names the problem's type.
issues
object[]
One entry for each field that the request got wrong, when the problem is about fields.
Show issues fields
Array items · object
code
string
required
A stable code for this field's problem.
field
string
required
The field as one string, such as patient.address.state or prescriptions[0].quantity.
message
string
required
What is wrong with the field and what to send, for a person to read.
path
string | integer[]
required
The field as a list of property names and array indexes.
Show path fields
Array items · string | integer
string | integer
instance
string
required
The path of the request.
requestId
string
required
Identifies the request, as its X-Request-Id header does. Send it when you report a problem.
status
integer
required
The HTTP status code of the response.
traceId
string
The request trace ID.
404 Not Found
application/problem+json
Problem
code
string
required
A stable code for the problem. Branch on it, not on detail.
detail
string
required
What went wrong and what to do, for a person to read.
title
string
required
A short summary of the problem's type.
type
string
required
A URI that names the problem's type.
issues
object[]
One entry for each field that the request got wrong, when the problem is about fields.
Show issues fields
Array items · object
code
string
required
A stable code for this field's problem.
field
string
required
The field as one string, such as patient.address.state or prescriptions[0].quantity.
message
string
required
What is wrong with the field and what to send, for a person to read.
path
string | integer[]
required
The field as a list of property names and array indexes.
Show path fields
Array items · string | integer
string | integer
instance
string
required
The path of the request.
requestId
string
required
Identifies the request, as its X-Request-Id header does. Send it when you report a problem.
status
integer
required
The HTTP status code of the response.
traceId
string
The request trace ID.
409 Conflict
application/problem+json
Problem409
All of · 1: Problem
code
string
required
A stable code for the problem. Branch on it, not on detail.
detail
string
required
What went wrong and what to do, for a person to read.
title
string
required
A short summary of the problem's type.
type
string
required
A URI that names the problem's type.
issues
object[]
One entry for each field that the request got wrong, when the problem is about fields.
Show issues fields
Array items · object
code
string
required
A stable code for this field's problem.
field
string
required
The field as one string, such as patient.address.state or prescriptions[0].quantity.
message
string
required
What is wrong with the field and what to send, for a person to read.
path
string | integer[]
required
The field as a list of property names and array indexes.
Show path fields
Array items · string | integer
string | integer
instance
string
required
The path of the request.
requestId
string
required
Identifies the request, as its X-Request-Id header does. Send it when you report a problem.
status
integer
required
The HTTP status code of the response.
traceId
string
The request trace ID.
All of · 2: object
data
object
Show data fields
orderId
string
Pattern: ^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$
practiceId
string
Pattern: ^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$
413 Content Too Large
application/problem+json
Problem
code
string
required
A stable code for the problem. Branch on it, not on detail.
detail
string
required
What went wrong and what to do, for a person to read.
title
string
required
A short summary of the problem's type.
type
string
required
A URI that names the problem's type.
issues
object[]
One entry for each field that the request got wrong, when the problem is about fields.
Show issues fields
Array items · object
code
string
required
A stable code for this field's problem.
field
string
required
The field as one string, such as patient.address.state or prescriptions[0].quantity.
message
string
required
What is wrong with the field and what to send, for a person to read.
path
string | integer[]
required
The field as a list of property names and array indexes.
Show path fields
Array items · string | integer
string | integer
instance
string
required
The path of the request.
requestId
string
required
Identifies the request, as its X-Request-Id header does. Send it when you report a problem.
status
integer
required
The HTTP status code of the response.
traceId
string
The request trace ID.
415 Unsupported Media Type
application/problem+json
code
"unsupported_media_type"
required
A stable code for the problem. Branch on it, not on detail.
detail
string
required
What went wrong and what to do, for a person to read.
title
string
required
A short summary of the problem's type.
type
string
required
A URI that names the problem's type.
instance
string
required
The path of the request.
requestId
string
required
Identifies the request, as its X-Request-Id header does. Send it when you report a problem.
status
integer
required
The HTTP status code of the response.
traceId
string
The request trace ID.
422 Unprocessable Content
application/problem+json
Problem
code
string
required
A stable code for the problem. Branch on it, not on detail.
detail
string
required
What went wrong and what to do, for a person to read.
title
string
required
A short summary of the problem's type.
type
string
required
A URI that names the problem's type.
issues
object[]
One entry for each field that the request got wrong, when the problem is about fields.
Show issues fields
Array items · object
code
string
required
A stable code for this field's problem.
field
string
required
The field as one string, such as patient.address.state or prescriptions[0].quantity.
message
string
required
What is wrong with the field and what to send, for a person to read.
path
string | integer[]
required
The field as a list of property names and array indexes.
Show path fields
Array items · string | integer
string | integer
instance
string
required
The path of the request.
requestId
string
required
Identifies the request, as its X-Request-Id header does. Send it when you report a problem.
status
integer
required
The HTTP status code of the response.
traceId
string
The request trace ID.
429 Too Many Requests
application/problem+json
Problem429
All of · 1: Problem
code
string
required
A stable code for the problem. Branch on it, not on detail.
detail
string
required
What went wrong and what to do, for a person to read.
title
string
required
A short summary of the problem's type.
type
string
required
A URI that names the problem's type.
issues
object[]
One entry for each field that the request got wrong, when the problem is about fields.
Show issues fields
Array items · object
code
string
required
A stable code for this field's problem.
field
string
required
The field as one string, such as patient.address.state or prescriptions[0].quantity.
message
string
required
What is wrong with the field and what to send, for a person to read.
path
string | integer[]
required
The field as a list of property names and array indexes.
Show path fields
Array items · string | integer
string | integer
instance
string
required
The path of the request.
requestId
string
required
Identifies the request, as its X-Request-Id header does. Send it when you report a problem.
status
integer
required
The HTTP status code of the response.
traceId
string
The request trace ID.
All of · 2: object
data
object
Show data fields
retryAfterSeconds
integer
required
Minimum: 1
Maximum: 9007199254740991
500 Internal Server Error
application/problem+json
Problem
code
string
required
A stable code for the problem. Branch on it, not on detail.
detail
string
required
What went wrong and what to do, for a person to read.
title
string
required
A short summary of the problem's type.
type
string
required
A URI that names the problem's type.
issues
object[]
One entry for each field that the request got wrong, when the problem is about fields.
Show issues fields
Array items · object
code
string
required
A stable code for this field's problem.
field
string
required
The field as one string, such as patient.address.state or prescriptions[0].quantity.
message
string
required
What is wrong with the field and what to send, for a person to read.
path
string | integer[]
required
The field as a list of property names and array indexes.
Show path fields
Array items · string | integer
string | integer
instance
string
required
The path of the request.
requestId
string
required
Identifies the request, as its X-Request-Id header does. Send it when you report a problem.
status
integer
required
The HTTP status code of the response.
traceId
string
The request trace ID.
503 Service Unavailable
application/problem+json
Problem
code
string
required
A stable code for the problem. Branch on it, not on detail.
detail
string
required
What went wrong and what to do, for a person to read.
title
string
required
A short summary of the problem's type.
type
string
required
A URI that names the problem's type.
issues
object[]
One entry for each field that the request got wrong, when the problem is about fields.
Show issues fields
Array items · object
code
string
required
A stable code for this field's problem.
field
string
required
The field as one string, such as patient.address.state or prescriptions[0].quantity.
message
string
required
What is wrong with the field and what to send, for a person to read.
path
string | integer[]
required
The field as a list of property names and array indexes.
Show path fields
Array items · string | integer
string | integer
instance
string
required
The path of the request.
requestId
string
required
Identifies the request, as its X-Request-Id header does. Send it when you report a problem.
status
integer
required
The HTTP status code of the response.
traceId
string
The request trace ID.