openapi: 3.1.0
info:
  title: authintix API
  version: "1.1.0"
  description: |
    Photo evidence API. Create capture requests, receive sealed photos.
    Every error has the shape `{ "error": { "code": "...", "message": "...", "request_id": "rid_..." } }`.
    Every /v1 response carries a `Request-Id` header. Guides: https://authintix.com/docs
servers:
  - url: https://authintix.com
security:
  - secretKey: []
components:
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      description: Secret key, `sk_test_…` or `sk_live_…`.
  schemas:
    Error:
      type: object
      required: [error]
      properties:
        error:
          type: object
          required: [code, message]
          properties:
            code: { type: string, examples: [plan_required, not_found, rate_limited] }
            message: { type: string }
    Shot:
      type: object
      required: [label]
      properties:
        key: { type: string, maxLength: 40 }
        label: { type: string, maxLength: 80 }
        hint: { type: string, maxLength: 160 }
    CreateRequest:
      type: object
      properties:
        template:
          type: string
          enum: [general, motor_claim, pre_inspection, property_claim, collateral, site_visit, bnpl_delivery, bnpl_merchant, proof_of_delivery, damaged_shipment]
          default: general
        shots: { type: array, maxItems: 12, items: { $ref: "#/components/schemas/Shot" }, description: Overrides the template's photos. }
        reference: { type: string, maxLength: 120 }
        name: { type: string, maxLength: 190 }
        phone: { type: string, description: International or local number; normalised to E.164. }
        email: { type: string, format: email }
        send_email: { type: boolean, default: false }
        instructions: { type: string, maxLength: 1000 }
        require_location: { type: boolean, default: true }
        expires_in_hours: { type: integer, minimum: 1, maximum: 720, default: 72 }
        locale: { type: string, enum: [en, ar], default: en }
        metadata: { type: object, additionalProperties: true, description: Up to 20 keys, returned as-is. }
        customer_id: { type: string, maxLength: 120, description: Member, policy or account number; links the person across requests for fraud checks. }
        id_check: { type: string, enum: [none, card, card_selfie], description: Adds live photos of the ID card. Default comes from the account's fraud settings. }
        asset: { type: string, maxLength: 160 }
        claim_value: { type: number, minimum: 0 }
        claim_currency: { type: string, pattern: '^[A-Z]{3}$' }
    CaptureRequest:
      type: object
      properties:
        id: { type: string, examples: [req_7RkQ2mXv9aLw4TzN8pYc] }
        object: { const: capture_request }
        mode: { type: string, enum: [test, live] }
        status: { type: string, enum: [open, completed, expired, canceled] }
        reference: { type: string }
        template: { type: string }
        recipient: { type: object, properties: { name: { type: string }, phone: { type: string }, email: { type: string }, customer_id: { type: [string, "null"] } } }
        instructions: { type: string }
        shots: { type: array, items: { $ref: "#/components/schemas/Shot" } }
        shots_required: { type: integer }
        require_location: { type: boolean }
        created_at: { type: string, format: date-time }
        opened_at: { type: [string, "null"], format: date-time }
        expires_at: { type: string, format: date-time }
        completed_at: { type: [string, "null"], format: date-time }
        metadata: { type: object }
        id_check: { type: string, enum: [none, card, card_selfie] }
        claim: { type: object, properties: { value: { type: [number, "null"] }, currency: { type: [string, "null"] }, asset: { type: [string, "null"] } } }
        risk:
          type: [object, "null"]
          properties:
            score: { type: integer, minimum: 0, maximum: 100 }
            level: { type: string, enum: [low, medium, high] }
            signals: { type: array, items: { type: object, properties: { code: { type: string }, title: { type: string }, detail: { type: string }, points: { type: integer } } } }
            ai_review: { type: [object, "null"] }
            assessed_at: { type: string, format: date-time }
        link: { type: string, description: Only in the create response. }
        whatsapp_url: { type: [string, "null"], description: Only in the create response. }
        captures: { type: array, items: { $ref: "#/components/schemas/Capture" }, description: Only when reading one request. }
    Capture:
      type: object
      properties:
        id: { type: string, examples: [cap_7RkQ2mXv9aLw4TzN8pYc] }
        object: { const: capture }
        mode: { type: string, enum: [test, live] }
        status: { type: string, enum: [received, signed, sealed] }
        shot: { type: string }
        level: { type: string, enum: [basic, device, attested] }
        source: { type: string, enum: [web, android, ios] }
        file: { type: object, properties: { sha256: { type: string }, size: { type: integer }, mime: { type: string }, width: { type: integer }, height: { type: integer } } }
        captured_at: { type: [string, "null"], format: date-time, description: Device clock. }
        received_at: { type: string, format: date-time }
        location: { type: [object, "null"], properties: { lat: { type: number }, lng: { type: number }, accuracy_m: { type: [number, "null"] }, flag: { type: [string, "null"] } } }
        seal: { type: object, properties: { sealed_at: { type: [string, "null"] }, key_id: { type: [string, "null"] }, timestamp: { type: [object, "null"] } } }
        verify_url: { type: string }
        evidence_url: { type: string }
        content_credentials:
          type: object
          properties:
            in_original: { type: [object, "null"], description: C2PA manifest found in the uploaded file, validated. }
            available: { type: boolean, description: A copy with a signed C2PA manifest can be downloaded. }
            download_url: { type: string }
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      schema: { type: string, maxLength: 120 }
      description: Retries with the same key and body return the first response (header Idempotent-Replayed true). Kept 24 hours.
  responses:
    Error:
      description: Error
      content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } }
paths:
  /v1/requests:
    post:
      summary: Create a capture request
      parameters: [{ $ref: "#/components/parameters/IdempotencyKey" }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: "#/components/schemas/CreateRequest" } } } }
      responses:
        "201": { description: Created, content: { application/json: { schema: { $ref: "#/components/schemas/CaptureRequest" } } } }
        "402": { $ref: "#/components/responses/Error" }
        "422": { $ref: "#/components/responses/Error" }
        "429": { $ref: "#/components/responses/Error" }
    get:
      summary: List capture requests
      parameters:
        - { name: status, in: query, schema: { type: string, enum: [open, completed, expired, canceled] } }
        - { name: q, in: query, schema: { type: string } }
        - { name: limit, in: query, schema: { type: integer, maximum: 100, default: 25 } }
        - { name: before, in: query, schema: { type: integer }, description: Use next_before from the previous page. }
      responses:
        "200": { description: OK }
  /v1/requests/{id}:
    get:
      summary: Read a request with its captures
      parameters: [{ name: id, in: path, required: true, schema: { type: string } }]
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/CaptureRequest" } } } }
        "404": { $ref: "#/components/responses/Error" }
  /v1/requests/{id}/cancel:
    post:
      summary: Cancel an open request
      parameters: [{ name: id, in: path, required: true, schema: { type: string } }]
      responses:
        "200": { description: Canceled }
        "409": { $ref: "#/components/responses/Error" }
  /v1/requests/{id}/simulate:
    post:
      summary: Test mode only — fill the remaining photos with sample images
      parameters: [{ name: id, in: path, required: true, schema: { type: string } }]
      responses:
        "201": { description: Simulated, content: { application/json: { schema: { type: object, properties: { object: { const: simulation }, request: { type: string }, captures: { type: array, items: { type: string } }, note: { type: string } } } } } }
        "403": { $ref: "#/components/responses/Error" }
        "409": { $ref: "#/components/responses/Error" }
  /v1/captures:
    get:
      summary: Latest 50 captures
      responses: { "200": { description: OK } }
  /v1/captures/{id}:
    get:
      summary: Read a capture
      parameters: [{ name: id, in: path, required: true, schema: { type: string } }]
      responses:
        "200": { description: OK, content: { application/json: { schema: { $ref: "#/components/schemas/Capture" } } } }
  /v1/captures/{id}/record:
    get:
      summary: Sealed record, Ed25519 signature, RFC 3161 token (base64) and live checks
      parameters: [{ name: id, in: path, required: true, schema: { type: string } }]
      responses: { "200": { description: OK } }
  /v1/captures/{id}/evidence:
    get:
      summary: Evidence report as PDF
      parameters: [{ name: id, in: path, required: true, schema: { type: string } }]
      responses:
        "200": { description: PDF, content: { application/pdf: {} } }
        "409": { $ref: "#/components/responses/Error" }
  /v1/captures/{id}/original:
    get:
      summary: The original file, byte for byte
      parameters: [{ name: id, in: path, required: true, schema: { type: string } }]
      responses: { "200": { description: Image } }
  /v1/captures/{id}/c2pa:
    get:
      summary: The photo with a signed C2PA manifest (Content Credentials)
      parameters: [{ name: id, in: path, required: true, schema: { type: string } }]
      responses:
        "200": { description: JPEG, content: { image/jpeg: {} } }
        "409": { $ref: "#/components/responses/Error" }
  /v1/verify/c2pa:
    post:
      summary: Public — read and validate Content Credentials in any file (not stored)
      security: []
      requestBody: { content: { multipart/form-data: { schema: { type: object, properties: { file: { type: string, format: binary } } } } } }
      responses: { "200": { description: OK } }
  /v1/verify/hash:
    post:
      summary: Public — look up a sealed capture by SHA-256
      security: []
      requestBody: { content: { application/json: { schema: { type: object, properties: { sha256: { type: string } } } } } }
      responses: { "200": { description: OK } }
  /.well-known/authintix-seal-key:
    get:
      summary: Public — Ed25519 key that signs every record
      security: []
      responses: { "200": { description: OK } }
webhooks:
  event:
    post:
      summary: Event delivered to your endpoint
      description: |
        Header `Authintix-Signature: t=<unix>,v1=<hex>` where v1 = HMAC-SHA256(secret, t + "." + body).
        Types: request.created, request.opened, request.completed, request.expired, request.canceled, request.risk_flagged, capture.sealed, capture.seal_failed, endpoint.ping (test event from the dashboard).
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                id: { type: string }
                type: { type: string }
                mode: { type: string }
                created_at: { type: string, format: date-time }
                data: { type: object }
      responses: { "2XX": { description: Acknowledge within 10 seconds. } }
