Cancel a letter: cancel_letter
Cancels a letter that has not gone to print: waiting for a person, queued or held. Held credits go back to the balance and an approval link stops working. After the print cut-off it is too late: the answer says so and nothing changes. A correction is a new letter. A group reference (grp_…) cancels every letter of it that can still be cancelled, and lists the ones it could not, each with why.
| MCP tool | cancel_letter |
| REST | POST /v1/letters/{letter}/cancel |
| CLI | atomside cancel-letter |
| Key needs | Send (letters:send) |
| Changes anything | Yes, and it cannot be undone. |
| Idempotency key | Not used. |
Example
A real call and its real answer, made against the API in test mode. A test runs it again and fails if the answer changes. Ids, keys and links are replaced with stand-ins.
A call that works
REST:
curl -X POST https://api.atomside.com/v1/letters/ltr_example000000004/cancel \
-H "Authorization: Bearer $ATOMSIDE_API_KEY"
MCP:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "cancel_letter",
"arguments": {
"letter": "ltr_example000000004"
}
}
}
CLI:
atomside cancel-letter \
--letter ltr_example000000004
The answer (HTTP 200; over MCP, the same JSON is the result's structuredContent):
{
"letter": "ltr_example000000004",
"status": "cancelled",
"money": {
"returned": {
"credits": 15,
"gbp": "1.50"
},
"say": "15 credits (£1.50) went back to the balance."
},
"says": "ltr_example000000004 was cancelled at 09:30 on Mon 16 Nov. It was not printed.",
"next": "Do not send it again unless your person asks."
}
Cancelling a group
REST:
curl -X POST https://api.atomside.com/v1/letters/grp_example000000003/cancel \
-H "Authorization: Bearer $ATOMSIDE_API_KEY"
MCP:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "cancel_letter",
"arguments": {
"letter": "grp_example000000003"
}
}
}
CLI:
atomside cancel-letter \
--letter grp_example000000003
The answer (HTTP 200; over MCP, the same JSON is the result's structuredContent):
{
"group": "grp_example000000003",
"cancelled": [
{
"n": 1,
"letter": "ltr_example000000014",
"returned": {
"credits": 15,
"gbp": "1.50"
}
},
{
"n": 2,
"letter": "ltr_example000000015",
"returned": {
"credits": 15,
"gbp": "1.50"
}
},
{
"n": 3,
"letter": "ltr_example000000016",
"returned": {
"credits": 15,
"gbp": "1.50"
}
}
],
"not_cancelled": [],
"money": {
"returned": {
"credits": 45,
"gbp": "4.50"
},
"say": "45 credits (£4.50) went back to the balance."
},
"says": "Cancelled 3 at 09:30 on Mon 16 Nov.",
"next": "Do not send them again unless your person asks."
}
Input
Over REST, fields in the path go in the path, GET fields in the query string, and POST fields in the JSON body. Over MCP, every field is an argument of the tool.
{
"type": "object",
"properties": {
"letter": {
"type": "string",
"description": "The letter id, ltr_…, or a group, grp_…."
}
},
"required": [
"letter"
],
"additionalProperties": false
}
Output
{
"anyOf": [
{
"type": "object",
"properties": {
"letter": {
"type": "string"
},
"status": {
"type": "string",
"const": "cancelled"
},
"money": {
"type": "object",
"properties": {
"returned": {
"type": "object",
"properties": {
"credits": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991,
"description": "Whole credits. 1 credit is 10p."
},
"gbp": {
"type": "string",
"pattern": "^-?\\d+\\.\\d{2}$",
"description": "The same amount in pounds, ex VAT, as a decimal string."
}
},
"required": [
"credits",
"gbp"
],
"additionalProperties": false,
"description": "An amount in credits, with pounds beside it."
},
"say": {
"type": "string",
"description": "A sentence to repeat to your person as it stands."
}
},
"required": [
"returned",
"say"
],
"additionalProperties": false
},
"says": {
"type": "string",
"description": "A sentence to repeat to your person as it stands."
},
"next": {
"type": "string"
}
},
"required": [
"letter",
"status",
"money",
"says",
"next"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"group": {
"type": "string"
},
"cancelled": {
"type": "array",
"items": {
"type": "object",
"properties": {
"n": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"letter": {
"type": "string"
},
"returned": {
"type": "object",
"properties": {
"credits": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991,
"description": "Whole credits. 1 credit is 10p."
},
"gbp": {
"type": "string",
"pattern": "^-?\\d+\\.\\d{2}$",
"description": "The same amount in pounds, ex VAT, as a decimal string."
}
},
"required": [
"credits",
"gbp"
],
"additionalProperties": false,
"description": "An amount in credits, with pounds beside it."
}
},
"required": [
"n",
"letter",
"returned"
],
"additionalProperties": false
},
"description": "Letters cancelled now, each with the credits it gave back."
},
"not_cancelled": {
"type": "array",
"items": {
"type": "object",
"properties": {
"n": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"letter": {
"type": "string"
},
"code": {
"type": "string",
"description": "The refusal cancelling it alone would give."
},
"say": {
"type": "string",
"description": "A sentence to repeat to your person as it stands."
}
},
"required": [
"n",
"letter",
"code",
"say"
],
"additionalProperties": false
},
"description": "Letters that could not be cancelled, and why: too late, or already settled."
},
"money": {
"type": "object",
"properties": {
"returned": {
"type": "object",
"properties": {
"credits": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991,
"description": "Whole credits. 1 credit is 10p."
},
"gbp": {
"type": "string",
"pattern": "^-?\\d+\\.\\d{2}$",
"description": "The same amount in pounds, ex VAT, as a decimal string."
}
},
"required": [
"credits",
"gbp"
],
"additionalProperties": false,
"description": "An amount in credits, with pounds beside it."
},
"say": {
"type": "string",
"description": "A sentence to repeat to your person as it stands."
}
},
"required": [
"returned",
"say"
],
"additionalProperties": false
},
"says": {
"type": "string",
"description": "A sentence to repeat to your person as it stands."
},
"next": {
"type": "string"
}
},
"required": [
"group",
"cancelled",
"not_cancelled",
"money",
"says",
"next"
],
"additionalProperties": false
}
]
}
Refusals
Every refusal has the same shape. Branch on code, answer and retry; repeat say to your person.
| Code | Answer | Retry | HTTP | What to do next |
|---|---|---|---|---|
key_missing | no | after_fix | 401 | Send the key as "Authorization: Bearer as_test_…". Ask your person if you have none. |
key_not_valid | no | never | 401 | Ask your person for a new key. There is no link: we cannot say whose it was. |
scope_missing | no | after_person | 403 | Ask your person to give the key that permission. |
invalid_request | no | after_fix | 400 | Fix the field named in details.field. The same idempotency key is fine. |
rate_limited | no | at_time | 429 | Wait. The same idempotency key never sends twice. |
try_again_shortly | no | at_time | 503 | Try again after retry_after with the same idempotency key. |
account_expired | no | never | 401 | Start again with start_account if your person still wants this. |
connection_ended | no | after_person | 401 | Tell your person. To carry on, they connect Atomside again in your assistant. |
letter_not_found | no | after_fix | 404 | Check the id with list_letters. |
too_late_to_cancel | no | never | 409 | Tell your person now. A correction has to be a new letter. |
already_cancelled | no | never | 409 | Do not send it again unless your person asks. |
approval_declined | no | after_fix | 422 | Change only what the reason asks. If no reason was given, ask your person. |
approval_expired | no | after_fix | 422 | Quote again once and pass on the new link. Then stop. |
declined_by_atomside | no | never | 422 | Do not reword it to get past us. Our note is in the console. |
print_failed | no | after_fix | 422 | Read the reason with get_letter, then quote again. |
returned_to_sender | no | never | 409 | Do not write there again until your person confirms the address. |
key_cannot_send | no | after_person | 403 | Give your person the quote to send, or the link to the key. |
not_found | no | after_fix | 404 | Check the name against the tool list or /v1/openapi.json. |