{
  "openapi": "3.1.0",
  "info": {
    "title": "GiftMatch API",
    "version": "1",
    "description": "A gift-idea assistant that shows its evidence. Authenticate with an API key (Authorization: Bearer <key> or X-API-Key). Only writing a report is billed, after it is delivered and only when the words were written by the model; the preview, the what-if re-ranking and reads are free. Prices in a report are catalogue estimates, never live prices, and availability is never verified."
  },
  "servers": [
    {
      "url": "https://giftmatch.sensifai.com"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {
      "apiKey": []
    }
  ],
  "paths": {
    "/api/v1/meta": {
      "get": {
        "summary": "Vocabularies",
        "operationId": "getMeta",
        "tags": [
          "Meta"
        ],
        "description": "The closed lists a brief is built from: occasions, relationships, regions, currencies, constraints, kinds, wrapping themes, evidence labels and limits.",
        "responses": {
          "200": {
            "description": "Vocabularies",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Meta"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/preview": {
      "post": {
        "summary": "Preview a brief (free)",
        "operationId": "preview",
        "tags": [
          "Reports"
        ],
        "description": "Checks the brief, shows how its words were understood, and returns the Go-ranked shortlist with template words. No model is called and nothing is billed.",
        "responses": {
          "200": {
            "description": "Preview",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Preview"
                }
              }
            }
          },
          "422": {
            "description": "The brief is invalid or nothing fits it"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Brief"
              }
            }
          }
        }
      }
    },
    "/api/v1/reports": {
      "post": {
        "summary": "Write a report (billed when AI-written)",
        "operationId": "startReport",
        "tags": [
          "Reports"
        ],
        "description": "Queues one gift report and returns 202 with a job to poll. It is billed only when the words were written by the model and the report is delivered; a refused brief, a template-only report and any failure bill nothing.",
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Accepted"
                }
              }
            }
          },
          "402": {
            "description": "Empty wallet"
          },
          "403": {
            "description": "No active subscription"
          },
          "422": {
            "description": "Invalid brief, or nothing fits it"
          },
          "429": {
            "description": "Hourly quota reached"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Brief"
              }
            }
          }
        }
      },
      "get": {
        "summary": "List reports",
        "operationId": "listReports",
        "tags": [
          "Reports"
        ],
        "description": "Newest first, including queued and failed ones.",
        "responses": {
          "200": {
            "description": "Reports",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ReportSummary"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ]
      }
    },
    "/api/v1/reports/{id}": {
      "get": {
        "summary": "Get a report",
        "operationId": "getReport",
        "tags": [
          "Reports"
        ],
        "description": "The delivered report: ideas with evidence labels, price bands (estimates), checks and extras.",
        "responses": {
          "200": {
            "description": "Report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportView"
                }
              }
            }
          },
          "404": {
            "description": "Unknown or no longer retained"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "delete": {
        "summary": "Delete a report",
        "operationId": "deleteReport",
        "tags": [
          "Reports"
        ],
        "description": "Deletes the report, its feedback, its share link and its history row.",
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "description": "Unknown"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/v1/reports/{id}/rerank": {
      "post": {
        "summary": "What-if re-ranking (free)",
        "operationId": "rerank",
        "tags": [
          "Reports"
        ],
        "description": "Re-ranks a delivered report under a different surprise setting, budget, deadline, kinds or count. Nothing is saved and no model is called.",
        "responses": {
          "200": {
            "description": "Re-ranked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Preview"
                }
              }
            }
          },
          "404": {
            "description": "Unknown"
          },
          "422": {
            "description": "Invalid change"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Rerank"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/v1/jobs/{id}": {
      "get": {
        "summary": "Poll a job",
        "operationId": "getJob",
        "tags": [
          "Jobs"
        ],
        "description": "queued, running, succeeded (report_id is set) or failed (error explains, in plain words, that nothing was charged).",
        "responses": {
          "200": {
            "description": "Job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "404": {
            "description": "Unknown"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing or invalid API key"
      }
    },
    "schemas": {
      "Brief": {
        "type": "object",
        "properties": {
          "recipient_id": {
            "type": "string"
          },
          "recipient_name": {
            "type": "string"
          },
          "occasion": {
            "type": "string"
          },
          "relationship": {
            "type": "string"
          },
          "age_band": {
            "type": "string"
          },
          "interests": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "dislikes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "past_gifts": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "owned": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "avoid": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "budget": {
            "type": "object",
            "properties": {
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "enum": [
                  "EUR",
                  "GBP",
                  "USD",
                  "CAD",
                  "AUD",
                  "CHF"
                ]
              }
            },
            "required": [
              "amount",
              "currency"
            ]
          },
          "region": {
            "type": "string"
          },
          "deadline": {
            "type": "string",
            "format": "date"
          },
          "occasion_date": {
            "type": "string",
            "format": "date"
          },
          "surprise": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "kinds": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "physical",
                "experience",
                "diy",
                "digital"
              ]
            }
          },
          "count": {
            "type": "integer",
            "minimum": 4,
            "maximum": 10
          },
          "language": {
            "type": "string",
            "enum": [
              "en",
              "nl",
              "fr",
              "de",
              "es"
            ]
          }
        },
        "required": [
          "occasion",
          "relationship",
          "interests",
          "budget"
        ]
      },
      "Rerank": {
        "type": "object",
        "properties": {
          "surprise": {
            "type": "integer"
          },
          "budget": {
            "type": "object",
            "properties": {
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "enum": [
                  "EUR",
                  "GBP",
                  "USD",
                  "CAD",
                  "AUD",
                  "CHF"
                ]
              }
            },
            "required": [
              "amount",
              "currency"
            ]
          },
          "deadline": {
            "type": "string"
          },
          "kinds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "count": {
            "type": "integer"
          }
        }
      },
      "Accepted": {
        "type": "object",
        "properties": {
          "job_id": {
            "type": "string"
          },
          "poll": {
            "type": "string"
          }
        }
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed"
            ]
          },
          "report_id": {
            "type": "string"
          },
          "occasion": {
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Evidence": {
        "type": "object",
        "properties": {
          "field": {
            "type": "string"
          },
          "label": {
            "type": "string",
            "enum": [
              "observed",
              "possible",
              "user_confirmed",
              "not_verifiable"
            ]
          },
          "note": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "url": {
            "type": "string"
          }
        }
      },
      "Idea": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "blurb": {
            "type": "string"
          },
          "rank": {
            "type": "integer"
          },
          "score": {
            "type": "integer"
          },
          "components": {
            "type": "object",
            "properties": {
              "relevance": {
                "type": "number"
              },
              "budget": {
                "type": "number"
              },
              "surprise": {
                "type": "number"
              },
              "timing": {
                "type": "number"
              },
              "context": {
                "type": "number"
              }
            }
          },
          "price_low": {
            "type": "integer"
          },
          "price_high": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "fit": {
            "type": "string",
            "enum": [
              "within",
              "stretch"
            ]
          },
          "lead_days": {
            "type": "integer"
          },
          "order_by": {
            "type": "string"
          },
          "timing": {
            "type": "string"
          },
          "matched": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "adjacent": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "surprise": {
            "type": "integer"
          },
          "effort": {
            "type": "integer"
          },
          "why": {
            "type": "string"
          },
          "why_source": {
            "type": "string"
          },
          "specifics": {
            "type": "string"
          },
          "evidence": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Evidence"
            }
          },
          "books": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string"
                },
                "author": {
                  "type": "string"
                },
                "year": {
                  "type": "integer"
                },
                "url": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Check": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "ok": {
            "type": "boolean"
          },
          "detail": {
            "type": "string"
          }
        }
      },
      "Result": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string"
          },
          "brief": {
            "$ref": "#/components/schemas/Brief"
          },
          "recognised": {
            "type": "object"
          },
          "ideas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Idea"
            }
          },
          "excluded": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "reason": {
                  "type": "string"
                },
                "detail": {
                  "type": "string"
                }
              }
            }
          },
          "extras": {
            "type": "object"
          },
          "reminders": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                }
              }
            }
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Check"
            }
          },
          "checks_passed": {
            "type": "boolean"
          },
          "candidates": {
            "type": "integer"
          },
          "unknowns": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "source_links": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ai_written": {
            "type": "boolean"
          },
          "model": {
            "type": "string"
          },
          "prompt": {
            "type": "string"
          },
          "language": {
            "type": "string"
          }
        }
      },
      "Preview": {
        "type": "object",
        "properties": {
          "report": {
            "$ref": "#/components/schemas/Result"
          }
        }
      },
      "ReportView": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "billed": {
            "type": "boolean"
          },
          "report": {
            "$ref": "#/components/schemas/Result"
          },
          "feedback": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "share": {
            "type": "object"
          }
        }
      },
      "ReportSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string"
          },
          "occasion": {
            "type": "string"
          },
          "relationship": {
            "type": "string"
          },
          "recipient": {
            "type": "string"
          },
          "top_idea": {
            "type": "string"
          },
          "ideas": {
            "type": "integer"
          },
          "budget": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          },
          "deadline": {
            "type": "string"
          },
          "ai_written": {
            "type": "boolean"
          },
          "checks_passed": {
            "type": "boolean"
          },
          "billed": {
            "type": "boolean"
          },
          "error": {
            "type": "string"
          }
        }
      },
      "Meta": {
        "type": "object",
        "properties": {
          "occasions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          },
          "relationships": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          },
          "age_bands": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          },
          "regions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          },
          "currencies": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          },
          "constraints": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          },
          "kinds": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          },
          "wrap_themes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          },
          "evidence_labels": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          },
          "rates": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            }
          },
          "limits": {
            "type": "object"
          },
          "catalogue_size": {
            "type": "integer"
          },
          "engine_version": {
            "type": "string"
          }
        }
      }
    }
  }
}