{
  "openapi": "3.1.0",
  "info": {
    "title": "SendForMe API",
    "version": "1.0.0",
    "description": "Your AI agent writes the letter (or you bring a PDF); we print it, mail it First-Class or Certified, and track it to the mailbox. Same behavior as the MCP tools. Auth: Bearer sfm_ key (from the first letter's setup, or /account). Previews need no key."
  },
  "servers": [
    {
      "url": "https://sendforme.co"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Address": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "company": {
            "type": "string"
          },
          "line1": {
            "type": "string"
          },
          "line2": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "zip": {
            "type": "string"
          },
          "country": {
            "type": "string",
            "description": "ISO 2-letter, default US"
          }
        },
        "required": [
          "line1"
        ]
      },
      "Letter": {
        "type": "object",
        "properties": {
          "to": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "company": {
                "type": "string"
              },
              "line1": {
                "type": "string"
              },
              "line2": {
                "type": "string"
              },
              "city": {
                "type": "string"
              },
              "state": {
                "type": "string"
              },
              "zip": {
                "type": "string"
              },
              "country": {
                "type": "string",
                "description": "ISO 2-letter, default US"
              }
            },
            "required": [
              "line1"
            ]
          },
          "from": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "company": {
                "type": "string"
              },
              "line1": {
                "type": "string"
              },
              "line2": {
                "type": "string"
              },
              "city": {
                "type": "string"
              },
              "state": {
                "type": "string"
              },
              "zip": {
                "type": "string"
              },
              "country": {
                "type": "string",
                "description": "ISO 2-letter, default US"
              }
            },
            "required": [
              "line1"
            ]
          },
          "recipients": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "company": {
                  "type": "string"
                },
                "line1": {
                  "type": "string"
                },
                "line2": {
                  "type": "string"
                },
                "city": {
                  "type": "string"
                },
                "state": {
                  "type": "string"
                },
                "zip": {
                  "type": "string"
                },
                "country": {
                  "type": "string",
                  "description": "ISO 2-letter, default US"
                }
              },
              "required": [
                "line1"
              ]
            },
            "description": "Mail merge (instead of to)"
          },
          "body": {
            "type": "string",
            "description": "Letter text, markdown. Only the body: no addresses, date or signature."
          },
          "pdf": {
            "type": "string",
            "description": "Upload id (f_...), https URL, or base64"
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "subject": {
            "type": "string"
          },
          "references": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "salutation": {
            "type": "string"
          },
          "closing": {
            "type": "string"
          },
          "signature": {
            "type": "string",
            "enum": [
              "script",
              "handwritten",
              "typed",
              "image",
              "none"
            ]
          },
          "signer_name": {
            "type": "string"
          },
          "signer_title": {
            "type": "string"
          },
          "enclosures": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "cc": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "postscript": {
            "type": "string"
          },
          "date": {
            "type": "string"
          },
          "font": {
            "type": "string",
            "enum": [
              "serif",
              "sans",
              "handwriting",
              "typewriter"
            ]
          },
          "letterhead": {
            "type": "string",
            "enum": [
              "none",
              "name",
              "full"
            ]
          },
          "mail_class": {
            "type": "string",
            "enum": [
              "first_class",
              "certified",
              "certified_return_receipt"
            ]
          },
          "color": {
            "type": "boolean"
          },
          "double_sided": {
            "type": "boolean"
          },
          "mail_date": {
            "type": "string",
            "format": "date"
          },
          "must_arrive_by": {
            "type": "string",
            "format": "date"
          },
          "pdf_placement": {
            "type": "string",
            "enum": [
              "auto",
              "first_page",
              "cover_page"
            ]
          },
          "label": {
            "type": "string"
          }
        }
      }
    }
  },
  "security": [
    {
      "bearer": []
    },
    {}
  ],
  "paths": {
    "/v1/letters/preview": {
      "post": {
        "operationId": "previewLetter",
        "summary": "Free proof, price, delivery estimate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Letter"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/letters": {
      "post": {
        "operationId": "sendLetter",
        "summary": "Mail a letter (letter_id from a preview, or the full request). 402 with setup_url the first time.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Letter"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "letter_id": {
                        "type": "string"
                      },
                      "batch_id": {
                        "type": "string"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scheduled"
          },
          "402": {
            "description": "needs_setup: show setup_url to the user"
          }
        }
      },
      "get": {
        "operationId": "listLetters",
        "summary": "Recent letters",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/letters/{letter_id}": {
      "get": {
        "operationId": "getLetter",
        "parameters": [
          {
            "name": "letter_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "wait",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "operationId": "cancelLetter",
        "parameters": [
          {
            "name": "letter_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/setups/{setup_code}": {
      "get": {
        "operationId": "waitForSetup",
        "parameters": [
          {
            "name": "setup_code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "wait",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/uploads": {
      "post": {
        "operationId": "createUpload",
        "summary": "One-time upload URL (PUT the bytes)",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/addresses/check": {
      "post": {
        "operationId": "checkAddress",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "address": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "company": {
                        "type": "string"
                      },
                      "line1": {
                        "type": "string"
                      },
                      "line2": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "state": {
                        "type": "string"
                      },
                      "zip": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string",
                        "description": "ISO 2-letter, default US"
                      }
                    },
                    "required": [
                      "line1"
                    ]
                  },
                  "query": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/guides/{kind}": {
      "get": {
        "operationId": "letterGuide",
        "parameters": [
          {
            "name": "kind",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/account": {
      "get": {
        "operationId": "getAccount",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  }
}