{
    "openapi": "3.1.0",
    "info": {
        "title": "Allegro Browser SDK API",
        "version": "0.0.1",
        "description": "Endpoints used by the Allegro Browser SDK."
    },
    "servers": [
        {
            "url": "https://{tenant}.allegro.io/api",
            "variables": {
                "tenant": {
                    "default": "example",
                    "description": "The tenant slug."
                }
            }
        }
    ],
    "security": [
        {
            "http": []
        }
    ],
    "paths": {
        "/entitlements": {
            "get": {
                "operationId": "audienceEntitlement.index",
                "description": "List all active entitlements for the authenticated audience member.",
                "summary": "List Active Entitlements",
                "tags": [
                    "AudienceEntitlement"
                ],
                "parameters": [
                    {
                        "name": "include",
                        "in": "query",
                        "schema": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "enum": [
                                    "audienceMember",
                                    "product"
                                ]
                            }
                        },
                        "explode": false
                    },
                    {
                        "name": "fields[entitlements]",
                        "in": "query",
                        "schema": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "enum": [
                                    "id",
                                    "product",
                                    "started_at",
                                    "ended_at",
                                    "note",
                                    "is_active",
                                    "created_at",
                                    "updated_at"
                                ]
                            }
                        },
                        "explode": false
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Array of `EntitlementResource`",
                        "content": {
                            "application/vnd.api+json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/EntitlementResource"
                                            }
                                        },
                                        "included": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/JsonApiResource"
                                            }
                                        }
                                    },
                                    "required": [
                                        "data"
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        },
        "/entitlements/{slug}": {
            "get": {
                "operationId": "audienceEntitlement.check",
                "description": "Check whether the authenticated member has an active entitlement for the given product slug.",
                "summary": "Entitlement Check",
                "tags": [
                    "AudienceEntitlement"
                ],
                "parameters": [
                    {
                        "name": "slug",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "anyOf": [
                                        {
                                            "type": "object",
                                            "properties": {
                                                "access": {
                                                    "type": "string"
                                                }
                                            },
                                            "required": [
                                                "access"
                                            ]
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "access": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "required": [
                                                "access"
                                            ]
                                        }
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        },
        "/external-profiles/{provider}": {
            "get": {
                "operationId": "audienceExternalProfile.show",
                "summary": "Get a single external profile for the authenticated audience member by provider",
                "tags": [
                    "AudienceExternalProfile"
                ],
                "parameters": [
                    {
                        "name": "provider",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "`AudienceMemberExternalProfileResource`",
                        "content": {
                            "application/vnd.api+json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/AudienceMemberExternalProfileResource"
                                        }
                                    },
                                    "required": [
                                        "data"
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        },
        "/checkout": {
            "post": {
                "operationId": "checkout.initiate",
                "description": "Creates a hosted checkout session for a term and returns the provider URL.\nJWT is optional \u2014 authenticated members get their details pre-filled.",
                "summary": "Initiate Checkout",
                "tags": [
                    "Checkout"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/CheckoutInitiateRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "checkout_url": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "checkout_url"
                                    ]
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    }
                },
                "security": []
            }
        },
        "/checkout/token/exchange": {
            "post": {
                "operationId": "checkoutToken.exchange",
                "description": "Exchange an allegro_purchase_token for a JWT and entitlement data.\nThe token format is {purchaseId}.{hmac}.",
                "summary": "Exchange Purchase Token",
                "tags": [
                    "CheckoutToken"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "token": {
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "token"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "jwt": {
                                            "type": "string"
                                        },
                                        "entitlement": {
                                            "type": "object",
                                            "properties": {
                                                "id": {
                                                    "type": "string"
                                                },
                                                "product": {
                                                    "type": "object",
                                                    "properties": {
                                                        "id": {
                                                            "type": "string"
                                                        },
                                                        "slug": {
                                                            "type": "string"
                                                        },
                                                        "name": {
                                                            "type": "string"
                                                        }
                                                    },
                                                    "required": [
                                                        "id",
                                                        "slug",
                                                        "name"
                                                    ]
                                                },
                                                "started_at": {
                                                    "type": "string"
                                                },
                                                "ended_at": {
                                                    "type": "string"
                                                },
                                                "is_active": {
                                                    "type": "string"
                                                }
                                            },
                                            "required": [
                                                "id",
                                                "product",
                                                "started_at",
                                                "ended_at",
                                                "is_active"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "jwt",
                                        "entitlement"
                                    ]
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    }
                },
                "security": []
            }
        },
        "/event": {
            "post": {
                "operationId": "event.create",
                "description": "Record a new event with the provided request data.",
                "summary": "Create Event",
                "tags": [
                    "Event"
                ],
                "responses": {
                    "201": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "event_id": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "event_id"
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        },
        "/authentication/identify": {
            "post": {
                "operationId": "authentication.identifySession",
                "description": "Create or retrieve an audience device session for the given email and device ID.\nIf the audience member does not exist, they will be created. Always returns an\nunauthenticated session JWT, even if the device was previously authenticated.",
                "summary": "Identify Session",
                "tags": [
                    "IdentifySession"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email"
                                    },
                                    "device_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    }
                                },
                                "required": [
                                    "email",
                                    "device_id"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "jwt": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "jwt"
                                    ]
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    }
                }
            }
        },
        "/interactions/{id}": {
            "get": {
                "operationId": "interaction.show",
                "description": "Retrieve a single interaction by its ID or slug. Published interactions are\npublicly accessible; unpublished interactions require authorization.",
                "summary": "Get Interaction",
                "tags": [
                    "Interaction"
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "403": {
                        "$ref": "#/components/responses/AuthorizationException"
                    }
                }
            }
        },
        "/authentication/magic-link/request": {
            "post": {
                "operationId": "magicLink.request",
                "description": "Send a magic link email to the provided address for passwordless authentication.\nCreates the audience member if they do not already exist. Rate limited to 3\nrequests per email per minute.",
                "summary": "Request Magic Link",
                "tags": [
                    "MagicLink"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email"
                                    },
                                    "device_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "return_url": {
                                        "type": "string",
                                        "format": "uri"
                                    },
                                    "data": {
                                        "type": [
                                            "array",
                                            "null"
                                        ],
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                },
                                "required": [
                                    "email",
                                    "device_id",
                                    "return_url"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "created": {
                                            "type": "string"
                                        },
                                        "jwt": {
                                            "type": "string"
                                        },
                                        "status": {
                                            "type": "string",
                                            "const": "ok"
                                        }
                                    },
                                    "required": [
                                        "created",
                                        "jwt",
                                        "status"
                                    ]
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    }
                },
                "security": []
            }
        },
        "/authentication/magic-link/validate": {
            "post": {
                "operationId": "magicLink.validate",
                "description": "Validate a magic link token and authenticate the device session. If the\nvalidating device differs from the requesting device, both sessions are\nauthenticated. The audience member's email is marked as verified upon success.",
                "summary": "Validate Magic Link",
                "tags": [
                    "MagicLink"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "token": {
                                        "type": "string"
                                    },
                                    "device_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    }
                                },
                                "required": [
                                    "token",
                                    "device_id"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "const": "Authentication successful."
                                        },
                                        "jwt": {
                                            "type": "string"
                                        },
                                        "return_url": {
                                            "type": "string"
                                        },
                                        "audience_member_created": {
                                            "type": "string"
                                        },
                                        "sessions_authenticated": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "required": [
                                        "message",
                                        "jwt",
                                        "return_url",
                                        "audience_member_created",
                                        "sessions_authenticated"
                                    ]
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    }
                },
                "security": []
            }
        },
        "/authentication/session": {
            "get": {
                "operationId": "session.get",
                "description": "Retrieve the current authenticated device session details.",
                "summary": "Get Session",
                "tags": [
                    "Session"
                ],
                "parameters": [
                    {
                        "name": "include",
                        "in": "query",
                        "schema": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "enum": [
                                    "audienceMember"
                                ]
                            }
                        },
                        "explode": false
                    },
                    {
                        "name": "fields[audience_device_sessions]",
                        "in": "query",
                        "schema": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "enum": [
                                    "is_authenticated",
                                    "authenticated_at",
                                    "created_at",
                                    "updated_at"
                                ]
                            }
                        },
                        "explode": false
                    }
                ],
                "responses": {
                    "200": {
                        "description": "`AudienceDeviceSessionResource`",
                        "content": {
                            "application/vnd.api+json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/AudienceDeviceSessionResource"
                                        },
                                        "included": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/JsonApiResource"
                                            }
                                        }
                                    },
                                    "required": [
                                        "data"
                                    ]
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "session.destroy",
                "description": "Log out and delete the current authenticated device session. A `logout` event\nis recorded before the session is removed.",
                "summary": "Destroy Session",
                "tags": [
                    "Session"
                ],
                "responses": {
                    "204": {
                        "description": "No content"
                    }
                }
            }
        },
        "/authentication/session/refresh": {
            "post": {
                "operationId": "session.refresh",
                "description": "Generate a new JWT for the current authenticated device session.",
                "summary": "Refresh Session Token",
                "tags": [
                    "Session"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "jwt": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "jwt"
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "http": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "JWT"
            }
        },
        "schemas": {
            "AudienceDeviceSessionResource": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "type": {
                        "type": "string",
                        "const": "audience_device_sessions"
                    },
                    "attributes": {
                        "type": "object",
                        "properties": {
                            "is_authenticated": {
                                "type": "string"
                            },
                            "authenticated_at": {
                                "type": "string"
                            },
                            "created_at": {
                                "type": "string"
                            },
                            "updated_at": {
                                "type": "string"
                            }
                        }
                    },
                    "relationships": {
                        "type": "object",
                        "properties": {
                            "audienceMember": {
                                "type": "object",
                                "properties": {
                                    "data": {
                                        "type": "object",
                                        "properties": {
                                            "id": {
                                                "type": "string"
                                            },
                                            "type": {
                                                "type": "string"
                                            }
                                        },
                                        "required": [
                                            "id",
                                            "type"
                                        ]
                                    }
                                },
                                "required": [
                                    "data"
                                ]
                            }
                        }
                    }
                },
                "required": [
                    "id",
                    "type"
                ],
                "title": "AudienceDeviceSessionResource"
            },
            "AudienceMemberExternalProfileResource": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "type": {
                        "type": "string",
                        "const": "audience_member_external_profiles"
                    },
                    "meta": {
                        "type": "object",
                        "properties": {
                            "created_at": {
                                "type": "string"
                            },
                            "updated_at": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "created_at",
                            "updated_at"
                        ]
                    }
                },
                "required": [
                    "id",
                    "type",
                    "meta"
                ],
                "title": "AudienceMemberExternalProfileResource"
            },
            "CheckoutInitiateRequest": {
                "type": "object",
                "properties": {
                    "plan_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "return_url": {
                        "type": "string",
                        "format": "uri"
                    }
                },
                "required": [
                    "plan_id",
                    "return_url"
                ],
                "title": "CheckoutInitiateRequest"
            },
            "EntitlementResource": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "type": {
                        "type": "string",
                        "const": "entitlements"
                    },
                    "attributes": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "product": {
                                "anyOf": [
                                    {
                                        "$ref": "#/components/schemas/ProductResource"
                                    },
                                    {
                                        "type": "object"
                                    }
                                ]
                            },
                            "started_at": {
                                "type": "string"
                            },
                            "ended_at": {
                                "type": "string"
                            },
                            "note": {
                                "type": "string"
                            },
                            "is_active": {
                                "type": "string"
                            },
                            "created_at": {
                                "type": "string"
                            },
                            "updated_at": {
                                "type": "string"
                            }
                        }
                    },
                    "relationships": {
                        "type": "object",
                        "properties": {
                            "audienceMember": {
                                "type": "object",
                                "properties": {
                                    "data": {
                                        "type": "object",
                                        "properties": {
                                            "id": {
                                                "type": "string"
                                            },
                                            "type": {
                                                "type": "string"
                                            }
                                        },
                                        "required": [
                                            "id",
                                            "type"
                                        ]
                                    }
                                },
                                "required": [
                                    "data"
                                ]
                            },
                            "product": {
                                "type": "object",
                                "properties": {
                                    "data": {
                                        "type": "object",
                                        "properties": {
                                            "id": {
                                                "type": "string"
                                            },
                                            "type": {
                                                "type": "string"
                                            }
                                        },
                                        "required": [
                                            "id",
                                            "type"
                                        ]
                                    }
                                },
                                "required": [
                                    "data"
                                ]
                            }
                        }
                    }
                },
                "required": [
                    "id",
                    "type"
                ],
                "title": "EntitlementResource"
            },
            "JsonApiResource": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "type": {
                        "type": "string"
                    }
                },
                "required": [
                    "id",
                    "type"
                ],
                "title": "JsonApiResource"
            },
            "ProductResource": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "type": {
                        "type": "string",
                        "const": "products"
                    },
                    "attributes": {
                        "type": "object",
                        "properties": {
                            "name": {
                                "type": "string"
                            },
                            "slug": {
                                "type": "string"
                            },
                            "description": {
                                "type": "string"
                            },
                            "created_at": {
                                "type": "string"
                            },
                            "updated_at": {
                                "type": "string"
                            }
                        }
                    }
                },
                "required": [
                    "id",
                    "type"
                ],
                "title": "ProductResource"
            }
        },
        "responses": {
            "ValidationException": {
                "description": "Validation error",
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "object",
                            "properties": {
                                "message": {
                                    "type": "string",
                                    "description": "Errors overview."
                                },
                                "errors": {
                                    "type": "object",
                                    "description": "A detailed description of each field that failed validation.",
                                    "additionalProperties": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                }
                            },
                            "required": [
                                "message",
                                "errors"
                            ]
                        }
                    }
                }
            },
            "AuthorizationException": {
                "description": "Authorization error",
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "object",
                            "properties": {
                                "message": {
                                    "type": "string",
                                    "description": "Error overview."
                                }
                            },
                            "required": [
                                "message"
                            ]
                        }
                    }
                }
            },
            "ModelNotFoundException": {
                "description": "Not found",
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "object",
                            "properties": {
                                "message": {
                                    "type": "string",
                                    "description": "Error overview."
                                }
                            },
                            "required": [
                                "message"
                            ]
                        }
                    }
                }
            }
        }
    }
}