{
    "openapi": "3.1.0",
    "info": {
        "title": "Attendir Widget API",
        "version": "1.0.0",
        "summary": "Public API behind the Attendir embeddable share widget",
        "description": "Attendir (https://attendir.com) is a B2B event marketing platform that turns event attendees into LinkedIn advocates. This specification documents the public, stateless HTTP API that powers the embeddable share widget.\n\nAuthorization model: every endpoint is scoped to a single campaign by its `share_link` — an unguessable UUID that acts as a capability token in the URL path. It ships inside the campaign's embed snippet, so possession of it authorizes exactly the widget-level operations documented here for that one campaign, and nothing else. There are no API keys and no OAuth scopes on this surface; Attendir does not currently expose a general-purpose account API (see https://attendir.com/docs — programmatic account access can be requested via info@attendir.com).\n\nAll endpoints are CORS-enabled. Every endpoint except GET /email-html is rate-limited. Responses carry the IETF `RateLimit-Policy` and `RateLimit` fields (draft-ietf-httpapi-ratelimit-headers) alongside the legacy `X-RateLimit-Limit` / `X-RateLimit-Remaining`; exceeding a limit returns 429 with `Retry-After`.\n\nErrors: every failure under /api answers JSON whatever Accept header you send. Failed validation is a 422 `ValidationError` (`message` plus per-field `errors`); every other failure is an `Error` — a stable, machine-readable `error` code (branch on this) and a human-readable `message` (do not). That includes paths that match no endpoint (404 `not_found`), a wrong method (405 `method_not_allowed`) and throttling (429 `too_many_requests`).",
        "contact": {
            "name": "Attendir",
            "url": "https://attendir.com/docs",
            "email": "info@attendir.com"
        },
        "license": {
            "name": "Proprietary",
            "url": "https://attendir.com/terms-conditions"
        }
    },
    "security": [],
    "externalDocs": {
        "description": "Attendir developer documentation",
        "url": "https://attendir.com/docs"
    },
    "servers": [
        {
            "url": "https://attendir.com"
        }
    ],
    "paths": {
        "/api/widget/{share_link}/config": {
            "get": {
                "operationId": "getWidgetConfig",
                "summary": "Campaign configuration for rendering the widget",
                "description": "Returns branding, event details, default share text, enabled channels, and feature flags for the campaign. Read-heavy and cacheable (Cache-Control is set).",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/shareLink"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Widget configuration",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WidgetConfig"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "No campaign exists for this share link",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "campaign_not_found"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Too many requests — per-endpoint rate limit exceeded",
                        "headers": {
                            "Retry-After": {
                                "$ref": "#/components/headers/Retry-After"
                            },
                            "RateLimit-Policy": {
                                "$ref": "#/components/headers/RateLimit-Policy"
                            },
                            "RateLimit": {
                                "$ref": "#/components/headers/RateLimit"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "too_many_requests",
                                    "message": "Too Many Attempts."
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/widget/{share_link}/impression": {
            "post": {
                "operationId": "recordWidgetImpression",
                "summary": "Record a widget impression",
                "description": "Fire-and-forget analytics ping sent when the widget loads on a page. Crawler user agents are silently excluded from analytics.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/shareLink"
                    }
                ],
                "responses": {
                    "201": {
                        "description": "Impression recorded",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "No campaign exists for this share link",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "campaign_not_found"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Too many requests — per-endpoint rate limit exceeded",
                        "headers": {
                            "Retry-After": {
                                "$ref": "#/components/headers/Retry-After"
                            },
                            "RateLimit-Policy": {
                                "$ref": "#/components/headers/RateLimit-Policy"
                            },
                            "RateLimit": {
                                "$ref": "#/components/headers/RateLimit"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "too_many_requests",
                                    "message": "Too Many Attempts."
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/widget/{share_link}/advocate": {
            "post": {
                "operationId": "createAdvocate",
                "summary": "Create or retrieve a per-attendee advocate record",
                "description": "Called lazily on the first share interaction. Returns the advocate id plus a per-advocate tracking slug/URL used to attribute registrations to this advocate's shares. Deduplicates by email within the campaign without revealing whether the email was already known.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/shareLink"
                    }
                ],
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "email": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "format": "email",
                                        "maxLength": 255
                                    },
                                    "name": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 255
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Advocate created or retrieved",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "advocate_id": {
                                            "type": "integer"
                                        },
                                        "tracking_slug": {
                                            "type": "string"
                                        },
                                        "tracking_url": {
                                            "type": "string",
                                            "format": "uri"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "The organizer's plan share limit has been reached",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "share_limit_reached",
                                    "message": "This campaign has reached its sharing limit."
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "No campaign exists for this share link",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "campaign_not_found"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Request body failed validation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ValidationError"
                                },
                                "example": {
                                    "message": "The email field must be a valid email address.",
                                    "errors": {
                                        "email": [
                                            "The email field must be a valid email address."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Too many requests — per-endpoint rate limit exceeded",
                        "headers": {
                            "Retry-After": {
                                "$ref": "#/components/headers/Retry-After"
                            },
                            "RateLimit-Policy": {
                                "$ref": "#/components/headers/RateLimit-Policy"
                            },
                            "RateLimit": {
                                "$ref": "#/components/headers/RateLimit"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "too_many_requests",
                                    "message": "Too Many Attempts."
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/widget/{share_link}/share": {
            "post": {
                "operationId": "recordShare",
                "summary": "Record a share action on a channel",
                "description": "Marks the advocate as having shared (on first action, gated by the organizer's plan limit) and records the share activity for analytics.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/shareLink"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "advocate_id",
                                    "channel"
                                ],
                                "properties": {
                                    "advocate_id": {
                                        "type": "integer"
                                    },
                                    "channel": {
                                        "type": "string",
                                        "enum": [
                                            "linkedin",
                                            "x",
                                            "whatsapp",
                                            "email",
                                            "copy_link"
                                        ]
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Share recorded",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "The organizer's plan share limit has been reached",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "share_limit_reached",
                                    "message": "This campaign has reached its sharing limit."
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "No campaign exists for this share link, or the advocate does not belong to it",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "examples": {
                                    "campaign_not_found": {
                                        "value": {
                                            "error": "campaign_not_found"
                                        }
                                    },
                                    "advocate_not_found": {
                                        "value": {
                                            "error": "advocate_not_found"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Request body failed validation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ValidationError"
                                },
                                "example": {
                                    "message": "The channel field is required.",
                                    "errors": {
                                        "channel": [
                                            "The channel field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Too many requests — per-endpoint rate limit exceeded",
                        "headers": {
                            "Retry-After": {
                                "$ref": "#/components/headers/Retry-After"
                            },
                            "RateLimit-Policy": {
                                "$ref": "#/components/headers/RateLimit-Policy"
                            },
                            "RateLimit": {
                                "$ref": "#/components/headers/RateLimit"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "too_many_requests",
                                    "message": "Too Many Attempts."
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/widget/{share_link}/linkedin/share": {
            "post": {
                "operationId": "publishLinkedInShare",
                "summary": "Publish a LinkedIn post for a connected attendee",
                "description": "Publishes the attendee's personalized share to LinkedIn. Requires the short-lived, single-use `widget_token` issued to the widget by the LinkedIn OAuth popup flow (started at GET /api/widget/{share_link}/linkedin/connect, a browser-facing popup endpoint rather than a JSON API — it also validates the embedding page's origin against the campaign's allowed-domains list). A missing, expired, already-used, or invalid token returns 401.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/shareLink"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "widget_token",
                                    "share_text"
                                ],
                                "properties": {
                                    "widget_token": {
                                        "type": "string",
                                        "description": "Short-lived token issued by the widget LinkedIn OAuth popup"
                                    },
                                    "share_text": {
                                        "type": "string"
                                    },
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "description": "Optional raffle contact email"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Post published",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "post_url": {
                                            "type": [
                                                "string",
                                                "null"
                                            ],
                                            "format": "uri"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Widget token missing, invalid, expired, or already used (tokens are single-use)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "invalid_token",
                                    "message": "Your session has expired. Please reconnect with LinkedIn."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "The organizer's plan share limit has been reached",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "share_limit_reached",
                                    "message": "This campaign has reached its sharing limit."
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "No campaign exists for this share link",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "campaign_not_found"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Request body failed validation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ValidationError"
                                },
                                "example": {
                                    "message": "The share text field is required.",
                                    "errors": {
                                        "share_text": [
                                            "The share text field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Too many requests — per-endpoint rate limit exceeded",
                        "headers": {
                            "Retry-After": {
                                "$ref": "#/components/headers/Retry-After"
                            },
                            "RateLimit-Policy": {
                                "$ref": "#/components/headers/RateLimit-Policy"
                            },
                            "RateLimit": {
                                "$ref": "#/components/headers/RateLimit"
                            },
                            "X-RateLimit-Limit": {
                                "$ref": "#/components/headers/X-RateLimit-Limit"
                            },
                            "X-RateLimit-Remaining": {
                                "$ref": "#/components/headers/X-RateLimit-Remaining"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "too_many_requests",
                                    "message": "Too Many Attempts."
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "LinkedIn rejected or failed the post — the token is consumed; reconnect and retry",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "linkedin_post_failed",
                                    "message": "Failed to post to LinkedIn."
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/widget/{share_link}/email-html": {
            "get": {
                "operationId": "getEmailHtml",
                "summary": "Static HTML share block for emails",
                "description": "Returns a self-contained HTML snippet (inline styles, no JavaScript) that organizers paste into confirmation emails so attendees can share from their inbox.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/shareLink"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Email-safe HTML snippet",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "html": {
                                            "type": "string"
                                        },
                                        "share_page_url": {
                                            "type": "string",
                                            "format": "uri"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "No campaign exists for this share link",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                },
                                "example": {
                                    "error": "campaign_not_found"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "parameters": {
            "shareLink": {
                "name": "share_link",
                "in": "path",
                "required": true,
                "description": "The campaign's share-link UUID. Acts as the capability token authorizing widget operations for this one campaign — treat it like a bearer credential scoped to the campaign. Found in the Embed Widget section of the campaign page inside Attendir.",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            }
        },
        "schemas": {
            "WidgetConfig": {
                "type": "object",
                "properties": {
                    "campaign": {
                        "type": "object",
                        "properties": {
                            "share_link": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "event_logo": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "uri"
                            },
                            "share_image": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "uri"
                            },
                            "font_family": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "raffle_enabled": {
                                "type": "boolean"
                            },
                            "raffle_collect_email": {
                                "type": "boolean"
                            },
                            "raffle_prize": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            }
                        }
                    },
                    "event": {
                        "type": "object",
                        "properties": {
                            "name": {
                                "type": "string"
                            },
                            "date": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "location": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "url": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "uri"
                            }
                        }
                    },
                    "share_text": {
                        "type": "string"
                    },
                    "share_limit_reached": {
                        "type": "boolean"
                    },
                    "share_count": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    },
                    "widget": {
                        "type": "object",
                        "properties": {
                            "theme": {
                                "type": "string",
                                "enum": [
                                    "light",
                                    "dark"
                                ]
                            },
                            "channels": {
                                "type": "array",
                                "items": {
                                    "type": "string",
                                    "enum": [
                                        "linkedin",
                                        "x",
                                        "whatsapp",
                                        "email",
                                        "copy_link"
                                    ]
                                }
                            },
                            "cta_text": {
                                "type": "string"
                            },
                            "show_share_count": {
                                "type": "boolean"
                            },
                            "position": {
                                "type": "string"
                            }
                        }
                    },
                    "share_page_url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "widget_version": {
                        "type": "string"
                    }
                }
            },
            "Error": {
                "type": "object",
                "description": "Every failure this API returns except a failed validation (see ValidationError).",
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "string",
                        "description": "Stable, machine-readable error code — branch on this. Operation-specific codes (campaign_not_found, advocate_not_found, share_limit_reached, invalid_token, linkedin_post_failed) are listed on each response; transport-level failures use the HTTP reason phrase in snake_case (not_found, method_not_allowed, too_many_requests).",
                        "examples": [
                            "campaign_not_found"
                        ]
                    },
                    "message": {
                        "type": "string",
                        "description": "Human-readable explanation, safe to show a person. Wording may change; do not parse it."
                    }
                }
            },
            "ValidationError": {
                "type": "object",
                "description": "The request body failed validation.",
                "required": [
                    "message",
                    "errors"
                ],
                "properties": {
                    "message": {
                        "type": "string",
                        "description": "Human-readable summary of the first failure."
                    },
                    "errors": {
                        "type": "object",
                        "description": "Field name → the messages for that field.",
                        "additionalProperties": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "headers": {
            "Retry-After": {
                "description": "Seconds until the limit resets.",
                "schema": {
                    "type": "integer"
                }
            },
            "RateLimit-Policy": {
                "description": "The quota policy, e.g. `\"widget-config\";q=120;w=60` — 120 requests per 60-second window (draft-ietf-httpapi-ratelimit-headers).",
                "schema": {
                    "type": "string"
                }
            },
            "RateLimit": {
                "description": "Remaining quota under that policy and, on a 429, seconds until it resets, e.g. `\"widget-config\";r=0;t=42`.",
                "schema": {
                    "type": "string"
                }
            },
            "X-RateLimit-Limit": {
                "description": "Legacy: requests allowed per window.",
                "schema": {
                    "type": "integer"
                }
            },
            "X-RateLimit-Remaining": {
                "description": "Legacy: requests left in the current window.",
                "schema": {
                    "type": "integer"
                }
            }
        }
    }
}
