Cancel an agreement for recurring payments
POST/v1/agreements/{agreementId}/cancel
You can use this endpoint to cancel a recurring payments agreement in the active status.
Requires a bearer token.
In this mock: Unlike the real service, agreements in created status can also be cancelled, so a demo does not need a completed payment first. Cancelled or inactive agreements return 400 P2501.
Path parameters
| Name | Type | Description |
|---|---|---|
agreementIdrequired |
string | The agreement_id of the agreement you are cancelling |
Example request
curl -X POST "https://publicapi.payments.platform-engineering.com/v1/agreements/{agreementId}/cancel" \
-H "Authorization: Bearer $TOKEN"
Responses
204: No Content
400: Cancellation of agreement failed
| Name | Type | Description |
|---|---|---|
code |
string | An API error codethat explains why the payment failed.<br><br>code only appears if the payment failed. |
description |
string | Additional details about the error. |
field |
string | The parameter in your request that's causing the error. |
header |
string | The header in your request that's causing the error. |
{
"code": "P0102",
"description": "Invalid attribute value: amount. Must be less than or equal to 10000000",
"field": "amount",
"header": "Idempotency-Key"
}
401: Your API key is missing or invalid. Read more about [authenticating GOV.UK Pay API requests](https://docs.payments.service.gov.uk/api_reference/#authentication)
404: Not found
| Name | Type | Description |
|---|---|---|
code |
string | An API error codethat explains why the payment failed.<br><br>code only appears if the payment failed. |
description |
string | Additional details about the error. |
field |
string | The parameter in your request that's causing the error. |
header |
string | The header in your request that's causing the error. |
{
"code": "P0102",
"description": "Invalid attribute value: amount. Must be less than or equal to 10000000",
"field": "amount",
"header": "Idempotency-Key"
}
429: Too many requests
| Name | Type | Description |
|---|---|---|
code |
string | A GOV.UK Pay API error code. You can find out more about this code in our documentation. |
description |
string | Additional details about the error |
{
"code": "P0900",
"description": "Too many requests"
}
500: Downstream system error
| Name | Type | Description |
|---|---|---|
code |
string | An API error codethat explains why the payment failed.<br><br>code only appears if the payment failed. |
description |
string | Additional details about the error. |
field |
string | The parameter in your request that's causing the error. |
header |
string | The header in your request that's causing the error. |
{
"code": "P0102",
"description": "Invalid attribute value: amount. Must be less than or equal to 10000000",
"field": "amount",
"header": "Idempotency-Key"
}