{
 "openapi": "3.1.0",
 "info": {
  "title": "Replikate.co developer sandbox",
  "version": "2026-11-10",
  "description": "Synthetic, in-memory mirror of the Replikate.co APIs that products and partners integrate with. Same paths, request validation, Ed25519 project signatures, response shapes and error codes as production. Nothing here bills, sends email, pays commissions or reaches production data. Responses carry X-Replikate-Mode: sandbox."
 },
 "externalDocs": {
  "url": "https://sandbox.replikate.co/"
 },
 "servers": [
  {
   "url": "https://api.sandbox.replikate.co"
  }
 ],
 "paths": {
  "/health": {
   "get": {
    "summary": "Liveness",
    "security": [],
    "responses": {
     "200": {
      "description": "Sandbox is up",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        },
        "example": {
         "status": "ok",
         "mode": "sandbox"
        }
       }
      }
     }
    }
   }
  },
  "/v1/projects/{project}/events": {
   "post": {
    "tags": [
     "Project ingestion"
    ],
    "summary": "Send a signed project event",
    "description": "Same contract as production. Signature message: `v1\\n<unix-seconds>\\n<project>\\n<exact body>`. The first receipt returns 202 `pending`; the sandbox then marks it processed, so an identical replay returns 200 `applied`. The same eventId with different content returns 409 `event_conflict`. No ledger effects are simulated.",
    "security": [
     {
      "projectSignature": []
     }
    ],
    "parameters": [
     {
      "name": "project",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9-]{1,62}$"
      },
      "description": "Your sandbox project slug (sbx-…, from GET /v1/sandbox/me)."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/EventInput"
       },
       "example": {
        "eventId": "3f0c3c5e-7d5f-4a8e-9a43-0d1c8c1b2a10",
        "type": "payment.collected",
        "data": {
         "provider": "airwallex",
         "providerAccount": "acct-sandbox",
         "paymentId": "pay_1",
         "customerId": "cust_1",
         "currency": "USD",
         "collectedMinor": "3200",
         "taxMinor": "0",
         "eligibleMinor": "3200",
         "settledAt": "2026-01-02T03:04:05.000Z"
        }
       }
      }
     }
    },
    "responses": {
     "202": {
      "description": "Received, pending",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Event"
        }
       }
      }
     },
     "200": {
      "description": "Replay of a known event",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Event"
        }
       }
      }
     },
     "400": {
      "description": "Invalid request",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "409": {
      "description": "Conflicts with the recorded result",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body over the limit",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/r/{project}/{code}/{version}": {
   "get": {
    "tags": [
     "Referrals"
    ],
    "summary": "Referral click",
    "description": "Redirects (303) to your configured referralDestination (default: this docs page) with the proof in the fragment `#partner_claim=<token>`. The seeded campaign is code `sandbox`, version `1`.",
    "security": [],
    "parameters": [
     {
      "name": "project",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9-]{1,62}$"
      },
      "description": "Your sandbox project slug (sbx-…, from GET /v1/sandbox/me)."
     },
     {
      "name": "code",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "version",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "303": {
      "description": "Redirect with partner_claim fragment"
     },
     "400": {
      "description": "Invalid request",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Temporarily unavailable",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/projects/{project}/referrals/bind": {
   "post": {
    "tags": [
     "Referrals"
    ],
    "summary": "Bind a referral proof to a signed-up customer",
    "security": [
     {
      "projectSignature": []
     }
    ],
    "parameters": [
     {
      "name": "project",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9-]{1,62}$"
      },
      "description": "Your sandbox project slug (sbx-…, from GET /v1/sandbox/me)."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/BindInput"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Attribution receipt (exact replay returns the same receipt)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/BindReceipt"
        }
       }
      }
     },
     "400": {
      "description": "Invalid request",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "409": {
      "description": "Conflicts with the recorded result",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Temporarily unavailable",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/discount-integrations/{project}/commands": {
   "post": {
    "tags": [
     "Discounts"
    ],
    "summary": "Signed checkout command",
    "description": "Signature scope is `discounts/<project>` (message `v1\\n<unix-seconds>\\ndiscounts/<project>\\n<exact body>`). Actions: `definition`, `bind`, `reserve`, `dispatch`, `record_checkout`, `redeem`, `release`. Seeded codes: SANDBOX20 (20%, first invoice), SANDBOX5OFF (USD 5.00 off, recurring, sandbox-plus monthly), SANDBOXDRAFT (draft until bound), SANDBOXSPENT (exhausted). Products `sandbox-plus`, `sandbox-pro`; periods `monthly`, `yearly`; currency USD. Discounts never change a price: send the amount your checkout charges and apply the returned payableMinor.",
    "security": [
     {
      "projectSignature": []
     }
    ],
    "parameters": [
     {
      "name": "project",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9-]{1,62}$"
      },
      "description": "Your sandbox project slug (sbx-…, from GET /v1/sandbox/me)."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DiscountCommand"
       },
       "example": {
        "action": "reserve",
        "data": {
         "operationId": "6a1f0d3e-2b4c-4d5e-8f60-718293a4b5c6",
         "customerId": "cust_1",
         "code": "SANDBOX20",
         "productId": "sandbox-plus",
         "priceId": "plus-monthly",
         "period": "monthly",
         "currency": "USD",
         "amountMinor": 1600
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Action result: definition → Definition; bind → {state:active}; reserve → Reservation; dispatch → {start}; record_checkout → {recorded:true}; redeem → {state:redeemed}; release → {state:released}",
      "content": {
       "application/json": {
        "schema": {
         "oneOf": [
          {
           "$ref": "#/components/schemas/Definition"
          },
          {
           "$ref": "#/components/schemas/Reservation"
          },
          {
           "type": "object"
          }
         ]
        }
       }
      }
     },
     "400": {
      "description": "Invalid request",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Not permitted",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "409": {
      "description": "Conflicts with the recorded result",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Temporarily unavailable",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/projects/{project}/partners/me": {
   "get": {
    "tags": [
     "Partner reads"
    ],
    "summary": "Your partner membership",
    "description": "Production authenticates partners with their OIDC bearer token; the sandbox key stands in for it.",
    "security": [
     {
      "sandboxKey": []
     }
    ],
    "parameters": [
     {
      "name": "project",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9-]{1,62}$"
      },
      "description": "Your sandbox project slug (sbx-…, from GET /v1/sandbox/me)."
     }
    ],
    "responses": {
     "200": {
      "description": "Partner",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Partner"
        }
       }
      }
     },
     "400": {
      "description": "Invalid request",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Temporarily unavailable",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/projects/{project}/campaigns": {
   "get": {
    "tags": [
     "Partner reads"
    ],
    "summary": "Your campaigns",
    "security": [
     {
      "sandboxKey": []
     }
    ],
    "parameters": [
     {
      "name": "project",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9-]{1,62}$"
      },
      "description": "Your sandbox project slug (sbx-…, from GET /v1/sandbox/me)."
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "string",
       "pattern": "^([1-9][0-9]?|100)$"
      }
     },
     {
      "name": "cursor",
      "in": "query",
      "schema": {
       "type": "string",
       "maxLength": 256
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Page of campaigns",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "items": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Campaign"
           }
          },
          "nextCursor": {
           "type": [
            "string",
            "null"
           ]
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Invalid request",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Temporarily unavailable",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/projects/{project}/statements": {
   "get": {
    "tags": [
     "Partner reads"
    ],
    "summary": "Earnings statements per currency",
    "security": [
     {
      "sandboxKey": []
     }
    ],
    "parameters": [
     {
      "name": "project",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9-]{1,62}$"
      },
      "description": "Your sandbox project slug (sbx-…, from GET /v1/sandbox/me)."
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "string",
       "pattern": "^([1-9][0-9]?|100)$"
      }
     },
     {
      "name": "cursor",
      "in": "query",
      "schema": {
       "type": "string",
       "maxLength": 256
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Page of balances",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "items": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Balance"
           }
          },
          "nextCursor": {
           "type": [
            "string",
            "null"
           ]
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Invalid request",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Temporarily unavailable",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/projects/{project}/statements/{currency}": {
   "get": {
    "tags": [
     "Partner reads"
    ],
    "summary": "Earnings statement for one currency",
    "security": [
     {
      "sandboxKey": []
     }
    ],
    "parameters": [
     {
      "name": "project",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9-]{1,62}$"
      },
      "description": "Your sandbox project slug (sbx-…, from GET /v1/sandbox/me)."
     },
     {
      "name": "currency",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[A-Z]{3}$"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Balance",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Balance"
        }
       }
      }
     },
     "400": {
      "description": "Invalid request",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Temporarily unavailable",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/newsletters/publications/{publication}/subscriptions": {
   "post": {
    "tags": [
     "Newsletter"
    ],
    "summary": "Request a subscription (double opt-in)",
    "description": "Production emails a confirmation link. The sandbox sends nothing and returns that token in the `X-Sandbox-Confirmation-Token` header instead (only when a new token is issued; a repeat within 10 minutes issues none).",
    "security": [
     {
      "sandboxKey": []
     }
    ],
    "parameters": [
     {
      "name": "publication",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Your sandbox publication (default `sandbox`)."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "additionalProperties": false,
        "required": [
         "email"
        ],
        "properties": {
         "email": {
          "type": "string",
          "format": "email"
         },
         "source": {
          "type": "string",
          "maxLength": 40
         },
         "attribution": {},
         "interests": {}
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Accepted",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        },
        "example": {
         "success": true,
         "status": "pending",
         "message": "Request received. If confirmation is needed, check your email. Already confirmed? You're all set."
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "422": {
      "description": "Invalid request body",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "503": {
      "description": "Temporarily unavailable",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     }
    }
   }
  },
  "/v1/newsletters/publications/{publication}/tokens/check": {
   "post": {
    "tags": [
     "Newsletter"
    ],
    "summary": "Token check",
    "security": [
     {
      "sandboxKey": []
     }
    ],
    "parameters": [
     {
      "name": "publication",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Your sandbox publication (default `sandbox`)."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "additionalProperties": false,
        "required": [
         "token"
        ],
        "properties": {
         "token": {
          "type": "string",
          "maxLength": 2048
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        },
        "example": {
         "success": true,
         "status": "pending",
         "subscriber_id": "5e0b...",
         "email": "reader@example.com",
         "revision": 2
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "403": {
      "description": "Not permitted",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "409": {
      "description": "Conflicts with the recorded result",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "422": {
      "description": "Invalid request body",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "503": {
      "description": "Temporarily unavailable",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     }
    }
   }
  },
  "/v1/newsletters/publications/{publication}/tokens/confirm": {
   "post": {
    "tags": [
     "Newsletter"
    ],
    "summary": "Token confirm",
    "security": [
     {
      "sandboxKey": []
     }
    ],
    "parameters": [
     {
      "name": "publication",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Your sandbox publication (default `sandbox`)."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "additionalProperties": false,
        "required": [
         "token"
        ],
        "properties": {
         "token": {
          "type": "string",
          "maxLength": 2048
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        },
        "example": {
         "success": true,
         "status": "confirmed"
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "403": {
      "description": "Not permitted",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "409": {
      "description": "Conflicts with the recorded result",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "422": {
      "description": "Invalid request body",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "503": {
      "description": "Temporarily unavailable",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     }
    }
   }
  },
  "/v1/newsletters/publications/{publication}/tokens/unsubscribe": {
   "post": {
    "tags": [
     "Newsletter"
    ],
    "summary": "Token unsubscribe",
    "security": [
     {
      "sandboxKey": []
     }
    ],
    "parameters": [
     {
      "name": "publication",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Your sandbox publication (default `sandbox`)."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "additionalProperties": false,
        "required": [
         "token"
        ],
        "properties": {
         "token": {
          "type": "string",
          "maxLength": 2048
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        },
        "example": {
         "success": true,
         "status": "unsubscribed"
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "403": {
      "description": "Not permitted",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "409": {
      "description": "Conflicts with the recorded result",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "422": {
      "description": "Invalid request body",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     },
     "503": {
      "description": "Temporarily unavailable",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/NewsletterError"
        }
       }
      }
     }
    }
   }
  },
  "/v1/sandbox/me": {
   "get": {
    "tags": [
     "Sandbox only"
    ],
    "summary": "Your sandbox tenant",
    "security": [
     {
      "sandboxKey": []
     }
    ],
    "responses": {
     "200": {
      "description": "Tenant",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Temporarily unavailable",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/sandbox/settings": {
   "put": {
    "tags": [
     "Sandbox only"
    ],
    "summary": "Register your project signing key",
    "description": "Signed routes verify Ed25519 signatures against the public key you register here (PEM SubjectPublicKeyInfo, as a production project registers it). Optional referralDestination: your https signup page for referral clicks. Kept across resets; cleared by a sandbox restart.",
    "security": [
     {
      "sandboxKey": []
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "additionalProperties": false,
        "required": [
         "signingPublicKey"
        ],
        "properties": {
         "signingPublicKey": {
          "type": "string"
         },
         "referralDestination": {
          "type": "string",
          "format": "uri"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Registered",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        },
        "example": {
         "project": "sbx-0123456789abcdef",
         "signingKeyRegistered": true,
         "referralDestination": ""
        }
       }
      }
     },
     "400": {
      "description": "Invalid request",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/sandbox/reset": {
   "post": {
    "tags": [
     "Sandbox only"
    ],
    "summary": "Reset your tenant to the deterministic seed",
    "description": "Clears your events, referral clicks/attributions, discount reservations and newsletter subscribers. Other tenants are unaffected.",
    "security": [
     {
      "sandboxKey": []
     }
    ],
    "responses": {
     "200": {
      "description": "Reset",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        },
        "example": {
         "project": "acme",
         "reset": true
        }
       }
      }
     },
     "400": {
      "description": "Invalid request",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing/invalid credential or signature",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Temporarily unavailable",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Error": {
    "type": "object",
    "required": [
     "error"
    ],
    "properties": {
     "error": {
      "type": "object",
      "required": [
       "code",
       "message",
       "requestId"
      ],
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       },
       "requestId": {
        "type": "string"
       }
      }
     }
    }
   },
   "NewsletterError": {
    "type": "object",
    "required": [
     "error"
    ],
    "properties": {
     "error": {
      "type": "string"
     }
    }
   },
   "EventInput": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "eventId",
     "type",
     "data"
    ],
    "properties": {
     "eventId": {
      "type": "string",
      "format": "uuid"
     },
     "type": {
      "type": "string",
      "enum": [
       "attribution.bound",
       "payment.collected",
       "payment.refunded",
       "payment.disputed",
       "payment.dispute_resolved",
       "financial.evidence_held",
       "financial.evidence_resolved"
      ]
     },
     "data": {
      "type": "object",
      "description": "Per-type payload, validated with production's schema (see apps/growth/docs/api.md)."
     }
    }
   },
   "Event": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid"
     },
     "projectId": {
      "type": "string",
      "format": "uuid"
     },
     "type": {
      "type": "string"
     },
     "state": {
      "type": "string",
      "enum": [
       "pending",
       "applied",
       "rejected"
      ]
     },
     "reason": {
      "type": [
       "string",
       "null"
      ]
     },
     "receivedAt": {
      "type": "string",
      "format": "date-time"
     },
     "processedAt": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     }
    }
   },
   "BindInput": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "type",
     "token",
     "customerId",
     "identity"
    ],
    "properties": {
     "type": {
      "const": "referral.bind"
     },
     "token": {
      "type": "string",
      "description": "partner_claim from the click redirect"
     },
     "customerId": {
      "type": "string"
     },
     "identity": {
      "type": "object",
      "required": [
       "issuer",
       "subject"
      ],
      "properties": {
       "issuer": {
        "type": "string"
       },
       "subject": {
        "type": "string"
       }
      }
     }
    }
   },
   "BindReceipt": {
    "type": "object",
    "properties": {
     "attributionId": {
      "type": "string",
      "format": "uuid"
     },
     "projectId": {
      "type": "string",
      "format": "uuid"
     },
     "customerId": {
      "type": "string"
     },
     "identity": {
      "type": "object"
     },
     "campaignId": {
      "type": "string",
      "format": "uuid"
     },
     "campaignCode": {
      "type": "string"
     },
     "campaignVersion": {
      "type": "integer"
     },
     "includedMarkets": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "boundAt": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "DiscountCommand": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "action",
     "data"
    ],
    "properties": {
     "action": {
      "type": "string",
      "enum": [
       "definition",
       "bind",
       "reserve",
       "dispatch",
       "record_checkout",
       "redeem",
       "release"
      ]
     },
     "data": {
      "type": "object",
      "description": "definition {codeId}; bind {codeId,binding:{couponId,definition}}; reserve ReservationInput; dispatch {reservationId}; record_checkout {reservationId,checkoutId}; redeem {reservationId,checkoutId,redemptionId}; release {reservationId,proof?:{CheckoutID,Status,ObservedAt,NoRedemption}}"
     }
    }
   },
   "Definition": {
    "type": "object",
    "properties": {
     "code": {
      "type": "string"
     },
     "kind": {
      "enum": [
       "percentage",
       "fixed"
      ]
     },
     "value": {
      "type": "integer",
      "description": "Basis points (percentage) or minor units (fixed)"
     },
     "currency": {
      "type": "string"
     },
     "duration": {
      "enum": [
       "first_invoice",
       "recurring"
      ]
     },
     "products": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "periods": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "maximumUses": {
      "type": "integer"
     },
     "expiresAt": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "ReservationInput": {
    "type": "object",
    "properties": {
     "operationId": {
      "type": "string",
      "format": "uuid"
     },
     "customerId": {
      "type": "string"
     },
     "code": {
      "type": "string"
     },
     "productId": {
      "type": "string"
     },
     "priceId": {
      "type": "string"
     },
     "period": {
      "type": "string"
     },
     "currency": {
      "type": "string"
     },
     "amountMinor": {
      "type": "integer"
     }
    }
   },
   "Reservation": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid"
     },
     "ventureId": {
      "type": "string",
      "format": "uuid"
     },
     "operationId": {
      "type": "string",
      "format": "uuid"
     },
     "customerId": {
      "type": "string"
     },
     "codeId": {
      "type": "string",
      "format": "uuid"
     },
     "couponId": {
      "type": "string"
     },
     "priceId": {
      "type": "string"
     },
     "currency": {
      "type": "string"
     },
     "discountMinor": {
      "type": "integer"
     },
     "payableMinor": {
      "type": "integer"
     },
     "duration": {
      "type": "string"
     },
     "state": {
      "enum": [
       "reserved",
       "dispatching",
       "redeemed",
       "released"
      ]
     },
     "checkoutId": {
      "type": "string"
     },
     "redemptionId": {
      "type": "string"
     }
    }
   },
   "Partner": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid"
     },
     "projectId": {
      "type": "string",
      "format": "uuid"
     },
     "displayName": {
      "type": "string"
     },
     "status": {
      "type": "string"
     },
     "version": {
      "type": "integer"
     },
     "createdAt": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "Campaign": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid"
     },
     "projectId": {
      "type": "string",
      "format": "uuid"
     },
     "partnerId": {
      "type": "string",
      "format": "uuid"
     },
     "code": {
      "type": "string"
     },
     "version": {
      "type": "integer"
     },
     "name": {
      "type": "string"
     },
     "commissionBps": {
      "type": "integer"
     },
     "holdDays": {
      "type": "integer"
     },
     "attributionDays": {
      "type": "integer"
     },
     "includedMarkets": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "createdAt": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "Balance": {
    "type": "object",
    "properties": {
     "currency": {
      "type": "string"
     },
     "pendingMinor": {
      "type": "string",
      "pattern": "^-?[0-9]+$",
      "description": "Integer minor units as a decimal string."
     },
     "availableMinor": {
      "type": "string",
      "pattern": "^-?[0-9]+$",
      "description": "Integer minor units as a decimal string."
     },
     "reservedMinor": {
      "type": "string",
      "pattern": "^-?[0-9]+$",
      "description": "Integer minor units as a decimal string."
     },
     "paidMinor": {
      "type": "string",
      "pattern": "^-?[0-9]+$",
      "description": "Integer minor units as a decimal string."
     },
     "liabilityMinor": {
      "type": "string",
      "pattern": "^-?[0-9]+$",
      "description": "Integer minor units as a decimal string."
     },
     "withdrawableMinor": {
      "type": "string",
      "pattern": "^-?[0-9]+$",
      "description": "Integer minor units as a decimal string."
     },
     "blockedReasons": {
      "type": "array",
      "items": {
       "type": "string"
      }
     }
    }
   }
  },
  "securitySchemes": {
   "sandboxKey": {
    "type": "http",
    "scheme": "bearer",
    "description": "Your rk_sandbox_ key from partners.replikate.co. Production uses a partner OIDC token or a newsletter service key on these routes."
   },
   "projectSignature": {
    "type": "apiKey",
    "in": "header",
    "name": "X-Replikate-Signature",
    "description": "Ed25519 signature (base64url, no padding) over `v1\\n<X-Replikate-Timestamp>\\n<project>\\n<exact body>`, with X-Replikate-Timestamp in unix seconds (±300 s)."
   }
  }
 }
}
