{
  "openapi": "3.1.0",
  "info": {
    "title": "Tabster agent API",
    "version": "1.0.0",
    "description": "Create a Tabster receipt from a photo or from line items and get a share link. Friends open the link in any browser, tap what they had, and see what they owe. No key or account needed."
  },
  "servers": [
    {
      "url": "https://tabster.ai"
    }
  ],
  "paths": {
    "/api/agent/receipts": {
      "post": {
        "operationId": "createReceipt",
        "summary": "Create a receipt and get its share link",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "image_url"
                    ],
                    "properties": {
                      "image_url": {
                        "type": "string",
                        "format": "uri",
                        "description": "Public https URL of the receipt photo or PDF"
                      },
                      "currency": {
                        "type": "string",
                        "description": "3-letter code, default USD"
                      },
                      "payer_name": {
                        "type": "string",
                        "description": "Name of the person who paid"
                      },
                      "agent_name": {
                        "type": "string",
                        "description": "Your assistant or product name (for our stats)"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "image_base64"
                    ],
                    "properties": {
                      "image_base64": {
                        "type": "string",
                        "description": "The photo, base64 (about 4 MB at most)"
                      },
                      "image_mime": {
                        "type": "string",
                        "description": "e.g. image/jpeg"
                      },
                      "currency": {
                        "type": "string",
                        "description": "3-letter code, default USD"
                      },
                      "payer_name": {
                        "type": "string",
                        "description": "Name of the person who paid"
                      },
                      "agent_name": {
                        "type": "string",
                        "description": "Your assistant or product name (for our stats)"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "parsed_receipt"
                    ],
                    "properties": {
                      "parsed_receipt": {
                        "type": "object",
                        "required": [
                          "items"
                        ],
                        "properties": {
                          "restaurant": {
                            "type": "string",
                            "description": "Merchant name"
                          },
                          "items": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "required": [
                                "description",
                                "price"
                              ],
                              "properties": {
                                "description": {
                                  "type": "string",
                                  "description": "Line item name as printed"
                                },
                                "price": {
                                  "type": "number",
                                  "description": "Line total as printed (negative for a discount)"
                                },
                                "quantity": {
                                  "type": "number",
                                  "description": "Quantity if printed (default 1)"
                                }
                              }
                            },
                            "maxItems": 200,
                            "description": "Every item line, in order"
                          },
                          "subtotal": {
                            "type": "number"
                          },
                          "tax": {
                            "type": "number",
                            "description": "Tax amount (not a percent)"
                          },
                          "surcharges": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "required": [
                                "description",
                                "amount"
                              ],
                              "properties": {
                                "description": {
                                  "type": "string"
                                },
                                "amount": {
                                  "type": "number"
                                }
                              }
                            },
                            "description": "Tip, service charge, delivery fee and other fees, as printed"
                          },
                          "total": {
                            "type": "number"
                          },
                          "date": {
                            "type": "string"
                          }
                        }
                      },
                      "currency": {
                        "type": "string",
                        "description": "3-letter code, default USD"
                      },
                      "payer_name": {
                        "type": "string",
                        "description": "Name of the person who paid"
                      },
                      "agent_name": {
                        "type": "string",
                        "description": "Your assistant or product name (for our stats)"
                      }
                    }
                  }
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "image"
                ],
                "properties": {
                  "image": {
                    "type": "string",
                    "format": "binary"
                  },
                  "currency": {
                    "type": "string",
                    "description": "3-letter code, default USD"
                  },
                  "payer_name": {
                    "type": "string",
                    "description": "Name of the person who paid"
                  },
                  "agent_name": {
                    "type": "string",
                    "description": "Your assistant or product name (for our stats)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "doc_id": {
                      "type": "string"
                    },
                    "share_url": {
                      "type": "string",
                      "description": "Give the person this link"
                    },
                    "share_prompt_url": {
                      "type": "string",
                      "description": "The same receipt, opening a native share sheet"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "processing",
                        "parsed"
                      ],
                      "description": "processing: a photo is being read; items fill in on the share page"
                    },
                    "receipt": {
                      "type": "object",
                      "description": "The finalized receipt, for parsed_receipt calls"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Nothing usable in the request"
          },
          "413": {
            "description": "Image too large"
          },
          "422": {
            "description": "The image could not be downloaded"
          },
          "429": {
            "description": "Too many receipts from this address; see Retry-After"
          }
        }
      }
    }
  }
}