{
    "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; exceeding a limit returns 429.",
        "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": {
                        "$ref": "#/components/responses/CampaignNotFound"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/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": {
                        "$ref": "#/components/responses/CampaignNotFound"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/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": {
                        "$ref": "#/components/responses/ShareLimitReached"
                    },
                    "404": {
                        "$ref": "#/components/responses/CampaignNotFound"
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationError"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/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": {
                        "$ref": "#/components/responses/ShareLimitReached"
                    },
                    "404": {
                        "description": "No campaign exists for this share link, or the advocate does not belong to it",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "string",
                                            "enum": [
                                                "campaign_not_found",
                                                "advocate_not_found"
                                            ]
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationError"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/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)"
                    },
                    "403": {
                        "$ref": "#/components/responses/ShareLimitReached"
                    },
                    "404": {
                        "$ref": "#/components/responses/CampaignNotFound"
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationError"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    },
                    "502": {
                        "description": "LinkedIn rejected or failed the post — the token is consumed; reconnect and retry"
                    }
                }
            }
        },
        "/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": {
                        "$ref": "#/components/responses/CampaignNotFound"
                    }
                }
            }
        }
    },
    "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 campaign's Widget tab inside Attendir.",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            }
        },
        "responses": {
            "CampaignNotFound": {
                "description": "No campaign exists for this share link",
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "object",
                            "properties": {
                                "error": {
                                    "type": "string",
                                    "const": "campaign_not_found"
                                }
                            }
                        }
                    }
                }
            },
            "ShareLimitReached": {
                "description": "The organizer's plan share limit has been reached",
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "object",
                            "properties": {
                                "error": {
                                    "type": "string",
                                    "const": "share_limit_reached"
                                },
                                "message": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            },
            "ValidationError": {
                "description": "Request body failed validation",
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "object",
                            "properties": {
                                "message": {
                                    "type": "string"
                                },
                                "errors": {
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            },
            "RateLimited": {
                "description": "Too many requests — per-endpoint rate limit exceeded"
            }
        },
        "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"
                    }
                }
            }
        }
    }
}
