> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fourdos.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Fill one ad slot

> Called from the club's page with its publishable `ek_live_` key; the request `Origin` must be on the key's allowlist and must be the ad unit's property. Without `identity_token` the viewer is anonymous. With a valid one the slot is targeted at that member, and when the fan holds the club's personalised content consent the impression and click are recorded against the member; otherwise they are recorded anonymously. A missing, malformed, expired or other-club token, and the unsigned `member_external_id` and `user_id` parameters older integrations send, all serve the request anonymously rather than failing. No sponsor surface ever shows a member.



## OpenAPI

````yaml https://api.develop.fourdos.dev/openapi/partner.json get /v1/ads/serve
openapi: 3.1.0
info:
  title: 4D OS Partner API
  version: 0.1.0
  description: >-
    REST API for 4D OS partners. Authenticate with your organization API key:
    `Authorization: Bearer <key>`.


    Requests and responses are JSON with `snake_case` field names. Errors share
    one envelope: `{ "error": { "code", "status", "message", "details"? } }`.


    Mutating endpoints that declare it accept an `Idempotency-Key` header so
    retries are safe.


    Bulk-migrating members? See the [Migrating to 4D
    guide](https://docs.fourdos.dev/walkthroughs/migrate-existing-members) for
    the canonical import schema, a worked example, and the `/v1/imports`
    sequence.
servers:
  - url: https://api.develop.fourdos.dev
security:
  - partnerApiKey: []
tags:
  - name: Users
    description: Create, read, and manage users and their org membership
  - name: Imports
    description: Bulk member import jobs (staging → validate → commit)
  - name: API keys
    description: Issue, list, and revoke server-side organization API keys
  - name: Modules
    description: >-
      Publish private modules, install visible modules, and manage their
      credentials
  - name: Ingest
    description: Receive signed native events from an installed module
  - name: Engagement
    description: Browser event tracking (publishable keys) and tracking-key management
  - name: Revenue
    description: Report sales and refunds for the club's revenue dashboards
  - name: Ad delivery
    description: Fill a club site's ad slots, for anonymous or signed-in fans
  - name: Ad entries
    description: Fans entering a sponsor's draw, reported by the club's backend
paths:
  /v1/ads/serve:
    get:
      tags:
        - Ad delivery
      summary: Fill one ad slot
      description: >-
        Called from the club's page with its publishable `ek_live_` key; the
        request `Origin` must be on the key's allowlist and must be the ad
        unit's property. Without `identity_token` the viewer is anonymous. With
        a valid one the slot is targeted at that member, and when the fan holds
        the club's personalised content consent the impression and click are
        recorded against the member; otherwise they are recorded anonymously. A
        missing, malformed, expired or other-club token, and the unsigned
        `member_external_id` and `user_id` parameters older integrations send,
        all serve the request anonymously rather than failing. No sponsor
        surface ever shows a member.
      operationId: serveAd
      parameters:
        - name: key
          in: query
          required: true
          schema:
            type: string
          description: Publishable `ek_live_` tracking key.
        - name: unit
          in: query
          required: true
          schema:
            type: string
          description: Ad unit code.
        - name: identity_token
          in: query
          required: false
          schema:
            type: string
          description: From `POST /v1/ads/identity-tokens`, for a signed-in fan.
      responses:
        '200':
          description: 'A fill, or `{ ad: null, reason: "no_fill" }`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServedAd'
        '401':
          description: Missing, unknown or revoked key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Origin missing or not on the key's allowlist
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Ad serve rate limit exceeded for this key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    ServedAd:
      type: object
      properties:
        ad:
          type:
            - object
            - 'null'
          properties:
            creative_id:
              type: string
              format: uuid
            campaign_id:
              type: string
              format: uuid
            unit_code:
              type: string
            width:
              type: integer
            height:
              type: integer
            format:
              type: string
            asset_url:
              type: string
              format: uri
            click_url:
              type: string
              format: uri
              description: The platform's click redirector, never the advertiser's URL.
            impression_url:
              type: string
              format: uri
            token:
              type: string
              description: Signed serve token for the impression beacon and the click.
          required:
            - creative_id
            - campaign_id
            - unit_code
            - width
            - height
            - format
            - asset_url
            - click_url
            - impression_url
            - token
        reason:
          type: string
          enum:
            - no_fill
          description: Present when `ad` is null.
      required:
        - ad
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            status:
              type: integer
            message:
              type: string
            details:
              type: object
              additionalProperties: true
          required:
            - code
            - status
            - message
      required:
        - error
  securitySchemes:
    partnerApiKey:
      type: http
      scheme: bearer
      description: >-
        Organization API key (`org_...`) sent as `Authorization: Bearer <key>`.
        Keys are scoped to one organization; every request operates within that
        tenant.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.