{
  "openapi": "3.1.0",
  "info": {
    "description": "API for customer-scoped operations including authentication, usage, and receipt uploads",
    "version": "1.0.0",
    "title": "Preternatural Customer API"
  },
  "paths": {
    "/api/client/projects/{projectId}/identify": {
      "post": {
        "summary": "Identify a customer with an identity token",
        "operationId": "identifyCustomer",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accessToken": {
                      "type": "string",
                      "minLength": 1
                    },
                    "refreshToken": {
                      "type": "string",
                      "minLength": 1
                    },
                    "customerId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "sandboxMode": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "accessToken",
                    "refreshToken",
                    "customerId",
                    "sandboxMode"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jwtToken": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "jwtToken"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/client/projects/{projectId}/oauth/token": {
      "post": {
        "summary": "Exchange a Modem sign-in code and its PKCE verifier for a session",
        "operationId": "exchangeOAuthCode",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accessToken": {
                      "type": "string",
                      "minLength": 1
                    },
                    "refreshToken": {
                      "type": "string",
                      "minLength": 1
                    },
                    "customerId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "sandboxMode": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "accessToken",
                    "refreshToken",
                    "customerId",
                    "sandboxMode"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "codeVerifier": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9._~-]{43,128}$"
                  }
                },
                "required": [
                  "code",
                  "codeVerifier"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/client/refresh": {
      "post": {
        "summary": "Refresh a customer session",
        "operationId": "refreshSession",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accessToken": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "accessToken"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "refreshToken": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "refreshToken"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/client/projects/{projectId}/customers/{customerId}/usage": {
      "get": {
        "summary": "Retrieve a customer's usage",
        "operationId": "retrieveCustomerUsage",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "usageLimits": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "rawAmount": {
                            "type": "number"
                          },
                          "allowanceValue": {
                            "type": "number"
                          },
                          "allowanceMetric": {
                            "type": "string",
                            "enum": [
                              "audioDurationMilliseconds",
                              "audioFileSizeBytes",
                              "costMicros",
                              "numberOfCharacters",
                              "numberOfImages",
                              "numberOfRequest",
                              "numberOfTokens"
                            ]
                          },
                          "remaining": {
                            "type": "number"
                          },
                          "usedPercentage": {
                            "type": "number"
                          },
                          "scopeValue": {
                            "type": "string"
                          },
                          "scopeKind": {
                            "type": "string",
                            "enum": [
                              "modelIdentifier",
                              "requestRegexPatterns"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "rawAmount",
                          "allowanceValue",
                          "allowanceMetric",
                          "remaining",
                          "usedPercentage",
                          "scopeValue",
                          "scopeKind"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "rateLimits": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "allowanceValue": {
                            "type": "number"
                          },
                          "allowanceMetric": {
                            "type": "string",
                            "enum": [
                              "audioDurationMilliseconds",
                              "audioFileSizeBytes",
                              "costMicros",
                              "numberOfCharacters",
                              "numberOfImages",
                              "numberOfRequest",
                              "numberOfTokens"
                            ]
                          },
                          "rateLimitFrequency": {
                            "type": "string",
                            "enum": [
                              "minute",
                              "hour",
                              "day"
                            ]
                          },
                          "scopeValue": {
                            "type": "string"
                          },
                          "scopeKind": {
                            "type": "string",
                            "enum": [
                              "modelIdentifier",
                              "requestRegexPatterns"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "allowanceValue",
                          "allowanceMetric",
                          "rateLimitFrequency",
                          "scopeValue",
                          "scopeKind"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "usageLimits",
                    "rateLimits"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/api/client/projects/{projectId}/customers/{customerId}/usage/percentage": {
      "get": {
        "summary": "Retrieve a customer's usage as a percentage",
        "operationId": "retrieveCustomerUsagePercentage",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "percentage": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "percentage"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/api/client/projects/{projectId}/customers/{customerId}/product": {
      "get": {
        "summary": "Retrieve a customer's current product",
        "operationId": "retrieveCustomerCurrentProduct",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "productId": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "sku": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "billingInterval": {
                          "type": "string"
                        },
                        "billingPeriod": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "periodInterval": {
                                  "type": "string"
                                },
                                "periodStart": {
                                  "anyOf": [
                                    {},
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "periodEnd": {
                                  "anyOf": [
                                    {},
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "daysRemaining": {
                                  "anyOf": [
                                    {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              },
                              "required": [
                                "periodInterval",
                                "periodStart",
                                "periodEnd",
                                "daysRemaining"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "productId",
                        "type",
                        "sku",
                        "billingInterval",
                        "billingPeriod"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/client/projects/{projectId}/customers/{customerId}/products/{sourceProductId}/upgrade-options": {
      "get": {
        "summary": "List eligible upgrade destinations",
        "operationId": "listCustomerUpgradeOptions",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceProductId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "starting_after",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "list"
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "product": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid",
                                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                              },
                              "displayName": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "displayName"
                            ],
                            "additionalProperties": false
                          },
                          "price": {
                            "type": "object",
                            "properties": {
                              "amount": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "currency": {
                                "type": "string",
                                "minLength": 3,
                                "maxLength": 3
                              }
                            },
                            "required": [
                              "amount",
                              "currency"
                            ],
                            "additionalProperties": false
                          },
                          "billingInterval": {
                            "type": "object",
                            "properties": {
                              "unit": {
                                "type": "string",
                                "enum": [
                                  "day",
                                  "week",
                                  "month",
                                  "year"
                                ]
                              },
                              "count": {
                                "type": "integer",
                                "exclusiveMinimum": 0,
                                "maximum": 9007199254740991
                              }
                            },
                            "required": [
                              "unit",
                              "count"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "product",
                          "price",
                          "billingInterval"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "hasMore"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/api/client/projects/{projectId}/customers/{customerId}/product-upgrades/process": {
      "post": {
        "summary": "Verify and process an existing product upgrade",
        "operationId": "processCustomerProductUpgrade",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "upgradeId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "pending_payment"
                          ]
                        },
                        "paymentUrl": {
                          "type": "string",
                          "format": "uri",
                          "description": "HTTP or HTTPS callback URL"
                        }
                      },
                      "required": [
                        "upgradeId",
                        "status",
                        "paymentUrl"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "upgradeId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "processing"
                          ]
                        }
                      },
                      "required": [
                        "upgradeId",
                        "status"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "upgradeId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "completed"
                          ]
                        }
                      },
                      "required": [
                        "upgradeId",
                        "status"
                      ],
                      "additionalProperties": false
                    }
                  ]
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "upgradeId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  }
                },
                "required": [
                  "upgradeId"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/client/projects/{projectId}/customers/{customerId}/product-upgrades/confirm": {
      "post": {
        "summary": "Confirm a previewed paid product upgrade",
        "operationId": "confirmCustomerProductUpgrade",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "upgradeId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "pending_payment"
                          ]
                        },
                        "paymentUrl": {
                          "type": "string",
                          "format": "uri",
                          "description": "HTTP or HTTPS callback URL"
                        }
                      },
                      "required": [
                        "upgradeId",
                        "status",
                        "paymentUrl"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "upgradeId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "processing"
                          ]
                        }
                      },
                      "required": [
                        "upgradeId",
                        "status"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "upgradeId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "completed"
                          ]
                        }
                      },
                      "required": [
                        "upgradeId",
                        "status"
                      ],
                      "additionalProperties": false
                    }
                  ]
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sourceProductId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "targetProductId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "required": [
                  "sourceProductId",
                  "targetProductId"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/client/projects/{projectId}/customers/{customerId}/product-upgrades/preview": {
      "post": {
        "summary": "Preview a paid product upgrade",
        "operationId": "previewCustomerProductUpgrade",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sourceProduct": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        },
                        "displayName": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "displayName"
                      ],
                      "additionalProperties": false
                    },
                    "targetProduct": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        },
                        "displayName": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "displayName"
                      ],
                      "additionalProperties": false
                    },
                    "currency": {
                      "type": "string",
                      "minLength": 3,
                      "maxLength": 3
                    },
                    "amountDue": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "lines": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "description": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "amount": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": [
                          "description",
                          "amount"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "sourceProduct",
                    "targetProduct",
                    "currency",
                    "amountDue",
                    "lines"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sourceProductId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "targetProductId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "required": [
                  "sourceProductId",
                  "targetProductId"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/client/projects/{projectId}/customers/{customerId}/products/active": {
      "get": {
        "summary": "List active subscribed products",
        "operationId": "listCustomerActiveProducts",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "starting_after",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "list"
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "product": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid",
                                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                              },
                              "displayName": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "displayName"
                            ],
                            "additionalProperties": false
                          },
                          "price": {
                            "type": "object",
                            "properties": {
                              "amount": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "currency": {
                                "type": "string",
                                "minLength": 3,
                                "maxLength": 3
                              }
                            },
                            "required": [
                              "amount",
                              "currency"
                            ],
                            "additionalProperties": false
                          },
                          "quantity": {
                            "type": "integer",
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991
                          },
                          "billingInterval": {
                            "type": "object",
                            "properties": {
                              "unit": {
                                "type": "string",
                                "enum": [
                                  "day",
                                  "week",
                                  "month",
                                  "year"
                                ]
                              },
                              "count": {
                                "type": "integer",
                                "exclusiveMinimum": 0,
                                "maximum": 9007199254740991
                              }
                            },
                            "required": [
                              "unit",
                              "count"
                            ],
                            "additionalProperties": false
                          },
                          "billingPeriod": {
                            "type": "object",
                            "properties": {
                              "startsAt": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                              },
                              "endsAt": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                              }
                            },
                            "required": [
                              "startsAt",
                              "endsAt"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "product",
                          "price",
                          "quantity",
                          "billingInterval",
                          "billingPeriod"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "hasMore"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/api/client/projects/{projectId}/customers/{customerId}/upload-receipt": {
      "post": {
        "summary": "Upload a StoreKit receipt",
        "operationId": "uploadReceipt",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "source": {
                        "type": "string",
                        "enum": [
                          "appStore"
                        ]
                      },
                      "customerId": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "productId": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "appStoreTransactionId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "sandboxMode": {
                        "type": "boolean"
                      },
                      "createdAt": {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                      },
                      "updatedAt": {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                      },
                      "tombstoned": {
                        "type": "boolean"
                      },
                      "tombstonedAt": {
                        "anyOf": [
                          {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "id",
                      "source",
                      "customerId",
                      "productId",
                      "appStoreTransactionId",
                      "sandboxMode",
                      "createdAt",
                      "updatedAt",
                      "tombstoned",
                      "tombstonedAt"
                    ],
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "storeKitReceiptV2": {
                    "type": "string",
                    "minLength": 1
                  },
                  "storeKitReceipt": {
                    "type": "object",
                    "properties": {
                      "receipt": {
                        "type": "string",
                        "minLength": 1
                      },
                      "device": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "receipt",
                      "device"
                    ],
                    "additionalProperties": false
                  },
                  "consumableStoreKitTransactionIds": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/client/projects/{projectId}/customers/{customerId}/stripe/{checkoutSessionId}": {
      "post": {
        "summary": "Process a completed Stripe Checkout Session",
        "operationId": "processStripeCheckoutSession",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "checkoutSessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "completed",
                        "failed",
                        "unpaid",
                        "expired"
                      ]
                    }
                  },
                  "required": [
                    "success",
                    "status"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/api/client/projects/{projectId}/products/{productId}/customers/{customerId}/stripe": {
      "post": {
        "summary": "Create a Stripe Checkout Session",
        "operationId": "createStripeCheckoutSession",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "checkoutSessionId": {
                      "type": "string"
                    },
                    "checkoutSessionURL": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "success",
                    "checkoutSessionId",
                    "checkoutSessionURL"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "successURL": {
                    "type": "string",
                    "format": "uri",
                    "description": "HTTP or HTTPS callback URL"
                  },
                  "cancelURL": {
                    "type": "string",
                    "format": "uri",
                    "description": "HTTP or HTTPS callback URL"
                  }
                },
                "required": [
                  "successURL",
                  "cancelURL"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    }
  }
}