Atomside docsThis page as Markdown

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 toolcancel_letter
RESTPOST /v1/letters/{letter}/cancel
CLIatomside cancel-letter
Key needsSend (letters:send)
Changes anythingYes, and it cannot be undone.
Idempotency keyNot 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.

CodeAnswerRetryHTTPWhat to do next
key_missingnoafter_fix401Send the key as "Authorization: Bearer as_test_…". Ask your person if you have none.
key_not_validnonever401Ask your person for a new key. There is no link: we cannot say whose it was.
scope_missingnoafter_person403Ask your person to give the key that permission.
invalid_requestnoafter_fix400Fix the field named in details.field. The same idempotency key is fine.
rate_limitednoat_time429Wait. The same idempotency key never sends twice.
try_again_shortlynoat_time503Try again after retry_after with the same idempotency key.
account_expirednonever401Start again with start_account if your person still wants this.
connection_endednoafter_person401Tell your person. To carry on, they connect Atomside again in your assistant.
letter_not_foundnoafter_fix404Check the id with list_letters.
too_late_to_cancelnonever409Tell your person now. A correction has to be a new letter.
already_cancellednonever409Do not send it again unless your person asks.
approval_declinednoafter_fix422Change only what the reason asks. If no reason was given, ask your person.
approval_expirednoafter_fix422Quote again once and pass on the new link. Then stop.
declined_by_atomsidenonever422Do not reword it to get past us. Our note is in the console.
print_failednoafter_fix422Read the reason with get_letter, then quote again.
returned_to_sendernonever409Do not write there again until your person confirms the address.
key_cannot_sendnoafter_person403Give your person the quote to send, or the link to the key.
not_foundnoafter_fix404Check the name against the tool list or /v1/openapi.json.