{
  "openapi": "3.0.0",
  "components": {
    "examples": {},
    "headers": {},
    "parameters": {},
    "requestBodies": {},
    "responses": {},
    "schemas": {
      "Marketplace": {
        "enum": [
          "AMAZON",
          "SHOPIFY",
          "UNKNOWN"
        ],
        "type": "string"
      },
      "Brand": {
        "properties": {
          "supported": {
            "type": "boolean",
            "description": "If `false`, then products from this brand cannot be purchased through the\nSell Anything API."
          },
          "marketplace": {
            "$ref": "#/components/schemas/Marketplace",
            "description": "Indicates what ecommerce platform the brand uses."
          },
          "id": {
            "type": "string",
            "description": "A unique identifier for the brand."
          }
        },
        "required": [
          "supported",
          "marketplace",
          "id"
        ],
        "type": "object"
      },
      "AuthenticationError": {
        "properties": {
          "name": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "stack": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "message"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "NotFoundError": {
        "properties": {
          "name": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "stack": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "message"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "FieldErrors": {
        "properties": {},
        "type": "object",
        "additionalProperties": {
          "properties": {
            "value": {},
            "message": {
              "type": "string"
            }
          },
          "required": [
            "message"
          ],
          "type": "object"
        }
      },
      "ValidateError": {
        "properties": {
          "name": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "stack": {
            "type": "string"
          },
          "status": {
            "type": "number",
            "format": "double"
          },
          "fields": {
            "$ref": "#/components/schemas/FieldErrors"
          }
        },
        "required": [
          "name",
          "message",
          "status",
          "fields"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "RuntimeError": {
        "properties": {
          "name": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "stack": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "message"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "Domain": {
        "type": "string",
        "example": "shop.aloyoga.com",
        "format": "hostname",
        "description": "Represents a valid domain name string.",
        "pattern": "^(?=.{1,253}$)(?!\\-)([a-zA-Z0-9\\-]{1,63}(?<!\\-)\\.)+[a-zA-Z]{2,63}$"
      },
      "Buyer": {
        "properties": {
          "postalCode": {
            "type": "string",
            "example": "10001",
            "maxLength": 255
          },
          "country": {
            "type": "string",
            "example": "US"
          },
          "province": {
            "type": "string",
            "example": "NY",
            "maxLength": 255
          },
          "city": {
            "type": "string",
            "example": "New York",
            "maxLength": 255
          },
          "address2": {
            "type": "string",
            "example": "Apt 1",
            "maxLength": 255
          },
          "address1": {
            "type": "string",
            "example": "123 Main St",
            "maxLength": 255
          },
          "phone": {
            "type": "string",
            "example": "5555555555"
          },
          "email": {
            "type": "string",
            "example": "john.doe@example.com"
          },
          "lastName": {
            "type": "string",
            "example": "Doe",
            "maxLength": 255
          },
          "firstName": {
            "type": "string",
            "example": "John",
            "maxLength": 255
          }
        },
        "required": [
          "postalCode",
          "country",
          "province",
          "city",
          "address1",
          "phone",
          "email",
          "lastName",
          "firstName"
        ],
        "type": "object"
      },
      "VariantSelection": {
        "description": "Represents variant selections for a product, such as size, color, etc.",
        "properties": {
          "value": {
            "description": "The value of the variant being selected. Match this value with what is used on the product page.",
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "number",
                "format": "double"
              }
            ],
            "example": "Small, Red, XS, L, etc.",
            "maxLength": 30
          },
          "label": {
            "description": "The label of the variant being selected. Match this label with what is used on the product page.",
            "type": "string",
            "example": "Size, Color, etc.",
            "maxLength": 30
          }
        },
        "required": [
          "value",
          "label"
        ],
        "type": "object"
      },
      "BaseCheckoutIntent": {
        "properties": {
          "variantSelections": {
            "items": {
              "$ref": "#/components/schemas/VariantSelection"
            },
            "type": "array"
          },
          "buyer": {
            "$ref": "#/components/schemas/Buyer"
          },
          "quantity": {
            "type": "number",
            "format": "integer"
          },
          "productUrl": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string"
          }
        },
        "required": [
          "buyer",
          "quantity",
          "productUrl",
          "createdAt",
          "id"
        ],
        "type": "object"
      },
      "RetrievingOfferCheckoutIntent": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BaseCheckoutIntent"
          },
          {
            "properties": {
              "state": {
                "type": "string",
                "enum": [
                  "retrieving_offer"
                ],
                "nullable": false
              }
            },
            "required": [
              "state"
            ],
            "type": "object"
          }
        ]
      },
      "Money": {
        "properties": {
          "currencyCode": {
            "type": "string"
          },
          "amountSubunits": {
            "type": "number",
            "format": "double"
          }
        },
        "required": [
          "currencyCode",
          "amountSubunits"
        ],
        "type": "object"
      },
      "Cost": {
        "properties": {
          "total": {
            "$ref": "#/components/schemas/Money"
          },
          "discount": {
            "$ref": "#/components/schemas/Money"
          },
          "tax": {
            "$ref": "#/components/schemas/Money"
          },
          "shipping": {
            "$ref": "#/components/schemas/Money"
          },
          "subtotal": {
            "$ref": "#/components/schemas/Money"
          }
        },
        "required": [
          "total",
          "subtotal"
        ],
        "type": "object"
      },
      "ShippingOption": {
        "properties": {
          "cost": {
            "$ref": "#/components/schemas/Money"
          },
          "id": {
            "type": "string"
          }
        },
        "required": [
          "cost",
          "id"
        ],
        "type": "object"
      },
      "Shipping": {
        "properties": {
          "availableOptions": {
            "items": {
              "$ref": "#/components/schemas/ShippingOption"
            },
            "type": "array"
          },
          "selectedOptionId": {
            "type": "string"
          }
        },
        "required": [
          "availableOptions"
        ],
        "type": "object"
      },
      "Offer": {
        "properties": {
          "shipping": {
            "$ref": "#/components/schemas/Shipping"
          },
          "cost": {
            "$ref": "#/components/schemas/Cost"
          }
        },
        "required": [
          "shipping",
          "cost"
        ],
        "type": "object"
      },
      "AwaitingConfirmationCheckoutIntent": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BaseCheckoutIntent"
          },
          {
            "properties": {
              "offer": {
                "$ref": "#/components/schemas/Offer"
              },
              "state": {
                "type": "string",
                "enum": [
                  "awaiting_confirmation"
                ],
                "nullable": false
              }
            },
            "required": [
              "offer",
              "state"
            ],
            "type": "object"
          }
        ]
      },
      "StripeTokenPaymentMethod": {
        "properties": {
          "stripeToken": {
            "type": "string",
            "example": "tok_1RkrWWHGDlstla3f1Fc7ZrhH"
          },
          "type": {
            "type": "string",
            "enum": [
              "stripe_token"
            ],
            "nullable": false,
            "example": "stripe_token"
          }
        },
        "required": [
          "stripeToken",
          "type"
        ],
        "type": "object"
      },
      "PaymentMethod": {
        "$ref": "#/components/schemas/StripeTokenPaymentMethod"
      },
      "PlacingOrderCheckoutIntent": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BaseCheckoutIntent"
          },
          {
            "properties": {
              "paymentMethod": {
                "$ref": "#/components/schemas/PaymentMethod"
              },
              "offer": {
                "$ref": "#/components/schemas/Offer"
              },
              "state": {
                "type": "string",
                "enum": [
                  "placing_order"
                ],
                "nullable": false
              }
            },
            "required": [
              "paymentMethod",
              "offer",
              "state"
            ],
            "type": "object"
          }
        ]
      },
      "CompletedCheckoutIntent": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BaseCheckoutIntent"
          },
          {
            "properties": {
              "paymentMethod": {
                "$ref": "#/components/schemas/PaymentMethod"
              },
              "offer": {
                "$ref": "#/components/schemas/Offer"
              },
              "state": {
                "type": "string",
                "enum": [
                  "completed"
                ],
                "nullable": false
              }
            },
            "required": [
              "paymentMethod",
              "offer",
              "state"
            ],
            "type": "object"
          }
        ]
      },
      "FailureReasonCode": {
        "type": "string",
        "enum": [
          "checkout_intent_expired",
          "payment_failed",
          "insufficient_stock",
          "product_out_of_stock",
          "offer_retrieval_failed",
          "order_placement_failed",
          "developer_not_found",
          "missing_shipping_method",
          "unsupported_currency",
          "unsupported_store_no_guest_checkout"
        ]
      },
      "FailureReason": {
        "properties": {
          "message": {
            "type": "string"
          },
          "code": {
            "$ref": "#/components/schemas/FailureReasonCode"
          }
        },
        "required": [
          "message",
          "code"
        ],
        "type": "object"
      },
      "FailedCheckoutIntent": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BaseCheckoutIntent"
          },
          {
            "properties": {
              "failureReason": {
                "$ref": "#/components/schemas/FailureReason"
              },
              "paymentMethod": {
                "$ref": "#/components/schemas/PaymentMethod"
              },
              "offer": {
                "$ref": "#/components/schemas/Offer"
              },
              "state": {
                "type": "string",
                "enum": [
                  "failed"
                ],
                "nullable": false
              }
            },
            "required": [
              "failureReason",
              "state"
            ],
            "type": "object"
          }
        ]
      },
      "CheckoutIntent": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/RetrievingOfferCheckoutIntent"
          },
          {
            "$ref": "#/components/schemas/AwaitingConfirmationCheckoutIntent"
          },
          {
            "$ref": "#/components/schemas/PlacingOrderCheckoutIntent"
          },
          {
            "$ref": "#/components/schemas/CompletedCheckoutIntent"
          },
          {
            "$ref": "#/components/schemas/FailedCheckoutIntent"
          }
        ]
      },
      "CheckoutIntentPostParams": {
        "properties": {
          "variantSelections": {
            "items": {
              "$ref": "#/components/schemas/VariantSelection"
            },
            "type": "array"
          },
          "buyer": {
            "$ref": "#/components/schemas/Buyer"
          },
          "quantity": {
            "type": "number",
            "format": "integer"
          },
          "productUrl": {
            "type": "string"
          }
        },
        "required": [
          "buyer",
          "quantity",
          "productUrl"
        ],
        "type": "object"
      },
      "CheckoutIntentConfirmParams": {
        "properties": {
          "paymentMethod": {
            "$ref": "#/components/schemas/PaymentMethod"
          }
        },
        "required": [
          "paymentMethod"
        ],
        "type": "object"
      },
      "CheckoutIntentPaymentParams": {
        "properties": {
          "paymentMethod": {
            "$ref": "#/components/schemas/PaymentMethod"
          }
        },
        "required": [
          "paymentMethod"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "basicAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Rye API key. Format: `Bearer <RYE_API_KEY>`"
      }
    }
  },
  "info": {
    "title": "checkout-intent-api",
    "version": "1.0.5",
    "license": {
      "name": "ISC"
    },
    "contact": {
      "name": "Rye Dev Team ",
      "email": "dev@rye.com"
    }
  },
  "paths": {
    "/health": {
      "get": {
        "operationId": "GetHealth",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message",
                    "status"
                  ],
                  "type": "object"
                }
              }
            }
          }
        },
        "description": "Simple check to confirm the API is running and accessible.",
        "summary": "Health",
        "security": [],
        "parameters": []
      }
    },
    "/api/v1/brands/domain/{domain}": {
      "get": {
        "operationId": "GetBrandByDomain",
        "responses": {
          "200": {
            "description": "Brand information including marketplace classification",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Brand"
                }
              }
            }
          },
          "401": {
            "description": "Authentication Failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthenticationError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidateError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuntimeError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          }
        },
        "description": "Retrieve brand information by domain name\n\nLook up a brand by its domain name (e.g. \"aloyoga.com\").\nReturns brand information including the marketplace type if the lookup succeeds.",
        "summary": "Brand by Domain",
        "security": [
          {
            "basicAuth": []
          }
        ],
        "parameters": [
          {
            "description": "The domain name to look up (e.g. \"aloyoga.com\")",
            "in": "path",
            "name": "domain",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Domain"
            }
          }
        ]
      }
    },
    "/api/v1/checkout-intents/{id}": {
      "get": {
        "operationId": "GetCheckoutIntent",
        "responses": {
          "200": {
            "description": "Checkout intent information",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutIntent"
                }
              }
            }
          },
          "401": {
            "description": "Authentication Failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthenticationError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          }
        },
        "description": "Retrieve a checkout intent by id\n\nReturns checkout intent information if the lookup succeeds.",
        "summary": "Checkout Intent by ID",
        "security": [
          {
            "basicAuth": []
          }
        ],
        "parameters": [
          {
            "description": "The id of the checkout intent to look up",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/v1/checkout-intents": {
      "post": {
        "operationId": "CreateCheckoutIntent",
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutIntent"
                }
              }
            }
          },
          "401": {
            "description": "Authentication Failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthenticationError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidateError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuntimeError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          }
        },
        "description": "Create a checkout intent with the given request body.",
        "summary": "Checkout Intent",
        "security": [
          {
            "basicAuth": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckoutIntentPostParams"
              }
            }
          }
        }
      }
    },
    "/api/v1/checkout-intents/{id}/confirm": {
      "post": {
        "operationId": "ConfirmCheckoutIntent",
        "responses": {
          "200": {
            "description": "The confirmed checkout intent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutIntent"
                }
              }
            }
          },
          "401": {
            "description": "Authentication Failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthenticationError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuntimeError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          }
        },
        "description": "Confirm a checkout intent with provided payment information\n\nConfirm means we have buyer's name, address and payment info, so we can\nmove forward to place the order.",
        "summary": "Confirm Checkout Intent",
        "security": [
          {
            "basicAuth": []
          }
        ],
        "parameters": [
          {
            "description": "The id of the checkout intent to confirm",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The request body containing the payment information",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckoutIntentConfirmParams",
                "description": "The request body containing the payment information"
              }
            }
          }
        }
      }
    },
    "/api/v1/checkout-intents/{id}/payment": {
      "post": {
        "operationId": "AddPaymentDetailsToCheckoutIntent",
        "responses": {
          "200": {
            "description": "Payment response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutIntent"
                }
              }
            }
          },
          "401": {
            "description": "Authentication Failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthenticationError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuntimeError"
                },
                "examples": {
                  "Example 1": {}
                }
              }
            }
          }
        },
        "description": "Add payment details to a checkout intent",
        "summary": "POST add payment method to checkout intent",
        "security": [
          {
            "basicAuth": []
          }
        ],
        "parameters": [
          {
            "description": "The id of the checkout intent to add payment details to",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The request body containing the payment details",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckoutIntentPaymentParams",
                "description": "The request body containing the payment details"
              }
            }
          }
        }
      }
    }
  },
  "servers": [
    {
      "url": "https://staging.api.rye.com/"
    }
  ]
}