{
    "openapi": "3.0.3",
    "info": {
        "title": "Get Race Store Purchases",
        "description": "Get race store purchases for a race.",
        "version": "1.0.0",
        "contact": {
            "name": "RunSignup API Support",
            "url": "https://runsignup.com/API",
            "email": "info@runsignup.com"
        }
    },
    "servers": [
        {
            "url": "https://api.runsignup.com/rest",
            "description": "Production API Server"
        }
    ],
    "tags": [
        {
            "name": "Race Store",
            "description": "APIs related to Race Store"
        }
    ],
    "components": {
        "schemas": {
            "Error": {
                "type": "object",
                "properties": {
                    "error": {
                        "type": "string",
                        "description": "Error message"
                    },
                    "details": {
                        "type": "object",
                        "description": "Additional error details",
                        "additionalProperties": true
                    }
                },
                "required": [
                    "error"
                ]
            },
            "BadRequestError": {
                "allOf": [
                    {
                        "$ref": "#/components/schemas/Error"
                    },
                    {
                        "description": "Error indicating invalid request parameters or structure"
                    }
                ]
            },
            "UnauthorizedError": {
                "allOf": [
                    {
                        "$ref": "#/components/schemas/Error"
                    },
                    {
                        "description": "Error indicating authentication failure"
                    }
                ]
            },
            "ForbiddenError": {
                "allOf": [
                    {
                        "$ref": "#/components/schemas/Error"
                    },
                    {
                        "description": "Error indicating the authenticated user lacks required permissions"
                    }
                ]
            },
            "NotFoundError": {
                "allOf": [
                    {
                        "$ref": "#/components/schemas/Error"
                    },
                    {
                        "description": "Error indicating the requested resource does not exist"
                    }
                ]
            },
            "ServerError": {
                "allOf": [
                    {
                        "$ref": "#/components/schemas/Error"
                    },
                    {
                        "description": "Error indicating an unexpected server-side issue"
                    }
                ]
            },
            "V2RaceStoreGetRaceStorePurchasesGetResponse": {
                "type": "object",
                "title": "Race Store Purchases Response",
                "description": "Race store purchases response",
                "properties": {
                    "purchases": {
                        "type": "array",
                        "description": "Race store purchases",
                        "items": {
                            "type": "object",
                            "description": "Race store purchase",
                            "properties": {
                                "purchase_id": {
                                    "type": "integer",
                                    "description": "Purchase ID"
                                },
                                "user_id": {
                                    "type": "integer",
                                    "description": "User ID"
                                },
                                "registration_id": {
                                    "type": "integer",
                                    "description": "Associated registration ID",
                                    "nullable": true
                                },
                                "purchase_ts": {
                                    "type": "integer",
                                    "description": "Purchase timestamp"
                                },
                                "purchase_amount": {
                                    "type": "string",
                                    "description": "Purchase amount",
                                    "format": "currency",
                                    "x-currency-symbol": "$",
                                    "x-decimal-places": 2,
                                    "pattern": "^\\$\\d+\\.\\d{2}$"
                                },
                                "amount_paid": {
                                    "type": "string",
                                    "description": "Amount paid",
                                    "format": "currency",
                                    "x-currency-symbol": "$",
                                    "x-decimal-places": 2,
                                    "pattern": "^\\$\\d+\\.\\d{2}$"
                                },
                                "items": {
                                    "type": "array",
                                    "description": "Purchased items",
                                    "items": {
                                        "type": "object",
                                        "description": "Purchased item",
                                        "properties": {
                                            "item_id": {
                                                "type": "integer",
                                                "description": "Item ID"
                                            },
                                            "item_name": {
                                                "type": "string",
                                                "description": "Item name"
                                            },
                                            "item_option": {
                                                "type": "string",
                                                "description": "Selected item option",
                                                "nullable": true
                                            },
                                            "quantity": {
                                                "type": "integer",
                                                "description": "Item quantity"
                                            }
                                        },
                                        "required": [
                                            "item_id",
                                            "item_name",
                                            "quantity"
                                        ]
                                    }
                                }
                            },
                            "required": [
                                "purchase_id",
                                "user_id",
                                "purchase_ts",
                                "purchase_amount",
                                "amount_paid",
                                "items"
                            ]
                        }
                    },
                    "next_url": {
                        "type": "string",
                        "description": "URL to get the next page of purchases",
                        "nullable": true
                    }
                },
                "required": [
                    "purchases"
                ],
                "example": {
                    "purchases": [
                        {
                            "purchase_id": 1234,
                            "user_id": 5678,
                            "registration_id": 9876,
                            "purchase_ts": 1774343700,
                            "purchase_amount": "$25.00",
                            "amount_paid": "$25.00",
                            "items": [
                                {
                                    "item_id": 1,
                                    "item_name": "Shirt",
                                    "item_option": "Large",
                                    "quantity": 1
                                }
                            ]
                        }
                    ],
                    "next_url": "https://example.com/rest/v2/race-store/get-race-store-purchases.json?format=json&race_id=1&min_purchase_ts=1774340000&next_token=eyJ2IjoxLCJwdXJjaGFzZV90cyI6MTc3NDM0MzcwMCwicHVyY2hhc2VfaWQiOjEyMzR9"
                }
            }
        },
        "securitySchemes": {
            "oauth2": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "JWT",
                "description": "OAuth2 Bearer token authentication. Use the access token obtained from the OAuth2 flow in the Authorization header as: `Authorization: Bearer {access_token}`. For complete OAuth2 implementation details including endpoints, parameters, and flow specifications, see the [OAuth2 Authentication API Specification](https://runsignup.com/API/OAuth2/openapi-spec.json). For client registration and setup guidance, visit the [OAuth2 Developer Guide](https://runsignup.com/Profile/OAuth2/DeveloperGuide)."
            },
            "apiKey": {
                "type": "apiKey",
                "in": "query",
                "name": "api_key",
                "description": "RunSignup API Key"
            },
            "apiSecret": {
                "type": "apiKey",
                "in": "query",
                "name": "api_secret",
                "description": "RunSignup API Secret"
            }
        }
    },
    "paths": {
        "/v2/race-store/get-race-store-purchases.json": {
            "get": {
                "tags": [
                    "Race Store"
                ],
                "summary": "Get Race Store Purchases",
                "description": "Get race store purchases for a race. This API supports OAuth2 Bearer token authentication.",
                "operationId": "v2_race_store_get_race_store_purchases_json",
                "parameters": [
                    {
                        "name": "api_key",
                        "in": "query",
                        "description": "API Key",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "api_secret",
                        "in": "query",
                        "description": "API Secret",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "rsu_api_key",
                        "in": "query",
                        "description": "API v2 key. If used, you must send the API secret in an HTTP header named X-RSU-API-SECRET.",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "sp_api_key",
                        "in": "query",
                        "description": "Super partner API key. If used, you must send the API secret in an HTTP header named X-RSU-API-SECRET.",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-RSU-API-SECRET",
                        "in": "header",
                        "description": "API v2 or super partner secret.",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "Authorization",
                        "in": "header",
                        "description": "Authorization Header. If using OAuth 2.0, fill this in with `Bearer <token>`.",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "race_id",
                        "in": "query",
                        "description": "ID of race.",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "num",
                        "in": "query",
                        "description": "Number of results per page (max 500).",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": "100"
                        }
                    },
                    {
                        "name": "min_purchase_ts",
                        "in": "query",
                        "description": "Only include purchases made on or after this Unix timestamp.",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "max_purchase_ts",
                        "in": "query",
                        "description": "Only include purchases made on or before this Unix timestamp.",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "next_token",
                        "in": "query",
                        "description": "Opaque cursor token from the previous page (only use this when included in the `next_url` of a previous response).",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "security": [
                    {
                        "oauth2": []
                    },
                    {
                        "apiKey": [],
                        "apiSecret": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Race Store Purchases Response - Race store purchases response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/V2RaceStoreGetRaceStorePurchasesGetResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BadRequestError"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UnauthorizedError"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ForbiddenError"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/NotFoundError"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ServerError"
                                }
                            }
                        }
                    }
                },
                "x-permissions": [
                    "partners",
                    "race_directors",
                    "timers"
                ]
            }
        }
    }
}