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

# Create Pixel

> Creates an ad-platform pixel, same as **Add pixel** in Tools -> Pixels. The answer carries the new `pixel_id`: attach it to campaigns with the attach endpoint.

Right after the save we send one check to the platform with your token. Its outcome lands in `health` within a minute: read the pixel list, or run the check endpoint again later. A TikTok pixel is checked only when it has a test event code; without one `health` stays `unknown` until the first event of a campaign.

Leave `events` out to get the defaults of the platform: Meta sends `Subscribe`, `Purchase` and `Lead`, TikTok sends `ViewContent`, `Subscribe`, `CompletePayment` and `Contact`, and renewals go as the purchase event.

Up to 50 active pixels per account.

**Errors** (`status: "error"`, HTTP 200):

- `422` `Incorrect platform: facebook | tiktok`.
- `422` `platform_pixel_id is required` or `access_token is required`.
- `422` `Incorrect events: array of {event, platform_event}`, `Unknown event: ...` or `Unknown platform event for ...`: the message lists the allowed values.
- `422` `Enable at least one event`.
- `422` `Event Source URL: enter a valid domain, e.g. https://yourdomain.com`, or a message that Meta blocks onlyfans.com as an event source.
- `422` `... is too long: N characters max`.
- `422` `Pixel limit reached (50). Archive unused pixels first`.
- `403` Access denied: missing / unknown key, or the account is not an active partner.
- `429` Rate limit exceeded (30 writes per minute per key, see the `Retry-After` header).
- `503` Service is temporarily unavailable: the platform did not answer in time. The action may still have been applied, read the pixel list before repeating it.

Same as **Add pixel** in **Tools -> Pixels**. The answer carries the new `pixel_id`: pass it to [attach](https://onlytraffic.com/docs/partners/api/campaign-pixel-attach.md) to put the pixel on a campaign. A new pixel sends nothing until it is attached.

## What to send

| Field | Required | What it is |
| - | - | - |
| `platform` | Yes | `facebook` (Meta Ads) or `tiktok` (TikTok Ads). Cannot be changed later |
| `platform_pixel_id` | Yes | Pixel ID (Dataset ID) from Meta Events Manager, or Pixel Code from TikTok Events Manager |
| `access_token` | Yes | Conversions API token (Meta) or Events API token (TikTok) |
| `pixel_name` | No | Your label for the pixel |
| `test_event_code` | No | Code from the platform's Test Events tool. Set it for the first test, clear it before the ads go live |
| `event_source_url` | No | Meta only: your own landing page address. Never an onlyfans.com address |
| `events` | No | Event mapping. Leave it out for the defaults |

Where the Pixel ID and the token come from is shown step by step in [Ad Platform Pixels](https://onlytraffic.com/docs/partners/revshare-pixels.md#step-1-get-the-pixel-id-and-the-access-token).

## The access token

The token is write-only. It is stored encrypted, no endpoint returns it, and it is not kept in the API request log. To replace it, send a new one with [update](https://onlytraffic.com/docs/partners/api/pixel-update.md).

## Events

Leave `events` out and the pixel gets the defaults of the platform:

| Event | Fires when | Meta | TikTok |
| - | - | - | - |
| `smartlink_click` | A visitor clicks the tracking link | Not available | `ViewContent` |
| `new_subscriber` | A fan subscribes | `Subscribe` | `Subscribe` |
| `new_transaction` | A fan pays: a subscription, a tip, a paid message or post, a stream | `Purchase` | `CompletePayment` |
| `new_renewal` | A recurring subscription payment (rebill) | `Purchase` | `CompletePayment` |
| `new_dialog` | A fan sends the model 3 or more messages | `Lead` | `Contact` |

Send `events` to choose yourself. The list is the whole mapping: an event you leave out is switched off.

```json theme={null}
"events": [
  { "event": "new_subscriber", "platform_event": "Subscribe" },
  { "event": "new_transaction", "platform_event": "Purchase" },
  { "event": "new_renewal", "platform_event": "Subscribe" }
]
```

In this example renewals reach Meta as `Subscribe`, every other payment as `Purchase`, and dialogs are not sent. A wrong name is answered with the list of allowed ones.

## After the save

We send one check to the platform with your token. Its outcome lands in `health` within a minute: read the [pixel list](https://onlytraffic.com/docs/partners/api/pixels.md), or see [Check Pixel](https://onlytraffic.com/docs/partners/api/pixel-check.md). A TikTok pixel is checked only when it has a test event code.

An account holds up to 50 active pixels.

## Errors

| Message | Meaning |
| - | - |
| `Incorrect platform: facebook \| tiktok` | `platform` is missing or unknown (`422`) |
| `platform_pixel_id is required`, `access_token is required` | A required field is missing (`422`) |
| `Incorrect events: array of {event, platform_event}` | `events` is not a list of pairs (`422`) |
| `Unknown event: …`, `Unknown platform event for …` | A name the platform does not have. The message lists the allowed names (`422`) |
| `Enable at least one event` | `events` is an empty list (`422`) |
| `Event Source URL: enter a valid domain, e.g. https://yourdomain.com` | `event_source_url` is not an address (`422`) |
| `Meta blocks onlyfans.com as an event source: use your own landing page domain, or leave the field empty` | `event_source_url` points to onlyfans.com (`422`) |
| `… is too long: N characters max` | A field is over its limit (`422`) |
| `Pixel limit reached (50). Archive unused pixels first` | The account already has 50 active pixels (`422`) |


## OpenAPI

````yaml api/openapi-partners.json POST /api/marketer/pixels/create
openapi: 3.0.2
info:
  title: OnlyTraffic Marketer API
  version: 2.5.0
  description: >-
    Partner (marketer) API for OnlyTraffic.


    **Authentication:** pass your API key in the `Authorization` header
    (`Authorization: your-api-key` or `Authorization: Bearer your-api-key`).
    Create keys in the partner cabinet: Tools -> API
    (https://partners.onlytraffic.com/tools/api). Up to 5 named keys per
    account, each **Full** or **Read-only**, with an optional expiry. Keys start
    with `ot_partners_` and are shown once, at creation. Read-only keys cannot
    call the `POST` endpoints (`error_code` 403, message `This API key is
    read-only`). An older legacy key keeps working with full access until you
    delete it on the same page.


    **Pagination:** all list endpoints accept `offset` (default 0) and `limit`
    (default 50, max 1000) as query parameters or JSON body fields.


    **Dates:** every timestamp field has two variants — an ISO 8601 string
    (`*_at`) and a Unix timestamp integer (`*_at_ts` / `*_ts`).


    **Writes:** a Full-access key reads and writes. Write endpoints are `POST`
    with a JSON body, accept public ids only (`revc_…`, `cplo_…`) and answer
    with the updated object in `data`. Rate limit: 120 requests per minute for
    reads, 30 per minute for writes, per account (shared by all its keys).
servers:
  - url: https://partners.onlytraffic.com
security: []
tags:
  - name: RevShare
    description: RevShare campaigns and financial data
  - name: CPL
    description: Cost-Per-Lead orders placed against your offers
  - name: CPC
    description: Cost-Per-Click orders and the category catalog
  - name: Subscribers
    description: Fans acquired through your campaigns
  - name: Stats
    description: Dashboard-style statistics widgets (fans, income, conversion)
  - name: Pixels
    description: >-
      Ad-platform pixels (Meta Ads, TikTok Ads) and the campaigns they are
      attached to
  - name: Write
    description: >-
      Write API: start / stop / update campaigns, accept / reject / stop CPL
      campaigns, attach / detach pixels, create / update / archive / check
      pixels (same key, same rules as the cabinet)
paths:
  /api/marketer/pixels/create:
    post:
      tags:
        - Write
      summary: Create a pixel
      description: >-
        Creates an ad-platform pixel, same as **Add pixel** in Tools -> Pixels.
        The answer carries the new `pixel_id`: attach it to campaigns with the
        attach endpoint.


        Right after the save we send one check to the platform with your token.
        Its outcome lands in `health` within a minute: read the pixel list, or
        run the check endpoint again later. A TikTok pixel is checked only when
        it has a test event code; without one `health` stays `unknown` until the
        first event of a campaign.


        Leave `events` out to get the defaults of the platform: Meta sends
        `Subscribe`, `Purchase` and `Lead`, TikTok sends `ViewContent`,
        `Subscribe`, `CompletePayment` and `Contact`, and renewals go as the
        purchase event.


        Up to 50 active pixels per account.


        **Errors** (`status: "error"`, HTTP 200):


        - `422` `Incorrect platform: facebook | tiktok`.

        - `422` `platform_pixel_id is required` or `access_token is required`.

        - `422` `Incorrect events: array of {event, platform_event}`, `Unknown
        event: ...` or `Unknown platform event for ...`: the message lists the
        allowed values.

        - `422` `Enable at least one event`.

        - `422` `Event Source URL: enter a valid domain, e.g.
        https://yourdomain.com`, or a message that Meta blocks onlyfans.com as
        an event source.

        - `422` `... is too long: N characters max`.

        - `422` `Pixel limit reached (50). Archive unused pixels first`.

        - `403` Access denied: missing / unknown key, or the account is not an
        active partner.

        - `429` Rate limit exceeded (30 writes per minute per key, see the
        `Retry-After` header).

        - `503` Service is temporarily unavailable: the platform did not answer
        in time. The action may still have been applied, read the pixel list
        before repeating it.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - platform
                - platform_pixel_id
                - access_token
              properties:
                platform:
                  type: string
                  enum:
                    - facebook
                    - tiktok
                  description: >-
                    Ad platform: `facebook` (Meta Ads) or `tiktok` (TikTok Ads).
                    Cannot be changed later.
                platform_pixel_id:
                  type: string
                  maxLength: 64
                  description: >-
                    The pixel on the platform side: Pixel ID (Dataset ID) from
                    Meta Events Manager or Pixel Code from TikTok Events
                    Manager.
                access_token:
                  type: string
                  maxLength: 1000
                  description: >-
                    Server access token of the pixel: the Conversions API token
                    from Meta Events Manager or the Events API token from TikTok
                    Events Manager. Write-only: stored encrypted, never returned
                    by any endpoint and not kept in request logs.
                pixel_name:
                  type: string
                  maxLength: 100
                  description: Your label for the pixel.
                test_event_code:
                  type: string
                  maxLength: 32
                  description: >-
                    Test event code from the platform's Test Events tool. While
                    it is set every event of the pixel carries it and shows up
                    in Test Events. Clear it before the ads go live.
                event_source_url:
                  type: string
                  maxLength: 255
                  description: >-
                    Meta only, optional: your own landing page address, sent as
                    the event source. Never an onlyfans.com address: Meta drops
                    those events. Leave it out to send events without a page
                    address.
                events:
                  type: array
                  items:
                    type: object
                    required:
                      - event
                      - platform_event
                    properties:
                      event:
                        type: string
                        enum:
                          - smartlink_click
                          - new_subscriber
                          - new_transaction
                          - new_renewal
                          - new_dialog
                        description: >-
                          What happened on the campaign: `new_subscriber` (a fan
                          subscribed), `new_transaction` (a fan paid: tip,
                          message, post, subscription, stream), `new_renewal` (a
                          renewal: a recurring subscription payment),
                          `new_dialog` (a fan sent the model 3 or more
                          messages), `smartlink_click` (a click on the tracking
                          link, TikTok pixels only).
                      platform_event:
                        type: string
                        description: >-
                          Event name the platform receives. Meta: `Purchase`,
                          `Subscribe`, `StartTrial`, `Lead`,
                          `CompleteRegistration`, `Contact`, `AddToCart`,
                          `InitiateCheckout`, `ViewContent`. TikTok:
                          `CompletePayment`, `Subscribe`,
                          `CompleteRegistration`, `Contact`, `SubmitForm`,
                          `PlaceAnOrder`, `InitiateCheckout`, `ClickButton`,
                          `ViewContent`.
                  description: >-
                    The whole event mapping: every event on the list is sent as
                    its `platform_event`, an event left out is switched off.
                    List `new_renewal` to send renewals, with the same platform
                    event as `new_transaction` or with another one to tell them
                    apart.
            example:
              platform: facebook
              platform_pixel_id: '1234567890123456'
              access_token: <Conversions API token>
              pixel_name: Main pixel
              test_event_code: TEST12345
              event_source_url: https://yourdomain.com
      responses:
        '200':
          description: Success (check `status`; errors are also HTTP 200)
          content:
            application/json:
              schema:
                oneOf:
                  - title: Success
                    type: object
                    properties:
                      status:
                        type: string
                        enum:
                          - success
                      message:
                        type: string
                      data:
                        $ref: '#/components/schemas/Pixel'
                  - $ref: '#/components/schemas/ErrorResponse'
              examples:
                success:
                  summary: Success
                  value:
                    status: success
                    message: Pixel created
                    data:
                      pixel_id: 0b9f6c1e-7a52-4d0e-9a3b-2f1c8e5d4a67
                      platform: facebook
                      platform_pixel_id: '1234567890123456'
                      pixel_name: Main pixel
                      events:
                        - event: new_subscriber
                          platform_event: Subscribe
                        - event: new_transaction
                          platform_event: Purchase
                        - event: new_renewal
                          platform_event: Purchase
                      status: active
                      event_source_url: https://yourdomain.com
                      test_mode: true
                      health: unknown
                      health_error: null
                      health_checked_at: null
                      health_checked_at_ts: null
                      campaigns: 0
                      active_campaigns: 0
                      created_at: '2026-11-23T20:15:00+03:00'
                      created_at_ts: 1795454100
                error:
                  summary: Error
                  value:
                    status: error
                    error_code: 422
                    message: access_token is required
      security:
        - api_key: []
components:
  schemas:
    Pixel:
      type: object
      description: One of your ad-platform pixels.
      properties:
        pixel_id:
          type: string
          format: uuid
          description: >-
            Pixel id in OnlyTraffic. This is the id the attach and detach
            endpoints take.
        platform:
          type: string
          enum:
            - facebook
            - tiktok
          description: 'Ad platform: `facebook` (Meta Ads) or `tiktok` (TikTok Ads).'
        platform_pixel_id:
          type: string
          description: >-
            The pixel on the platform side: Pixel ID from Meta Events Manager or
            Pixel Code from TikTok Events Manager.
        pixel_name:
          type: string
          description: >-
            Pixel name from Tools -> Pixels; an empty string when the pixel has
            no name.
        events:
          type: array
          items:
            $ref: '#/components/schemas/PixelEvent'
          description: >-
            Event mapping of the pixel: which platform event each campaign event
            becomes. Events that are switched off are not listed. Renewals are
            their own entry (`new_renewal`): unless set otherwise they are sent
            as the same platform event as `new_transaction`.
        status:
          type: string
          enum:
            - active
            - archived
          description: >-
            `active` pixels can be attached to campaigns. An `archived` pixel
            sends nothing and is attached to no campaign.
        event_source_url:
          type: string
          nullable: true
          description: >-
            Meta only: your own landing page address sent as the event source of
            every event; null when not set.
        test_mode:
          type: boolean
          description: >-
            `true` when a test event code is set on the pixel: its events land
            in the platform's Test Events tool.
        health:
          type: string
          enum:
            - healthy
            - error
            - unknown
          description: >-
            Outcome of the latest send or check of the pixel: `healthy`,
            `error`, or `unknown` when nothing was sent or checked yet.
        health_error:
          type: string
          nullable: true
          description: >-
            What the platform answered when `health` is `error`, for example an
            expired access token; null otherwise.
        health_checked_at:
          type: string
          format: date-time
          nullable: true
          description: >-
            Time of the latest send or check, ISO 8601; null when there was
            none.
        health_checked_at_ts:
          type: integer
          nullable: true
        campaigns:
          type: integer
          description: Campaigns the pixel is attached to, completed ones included.
        active_campaigns:
          type: integer
          description: Active campaigns the pixel is attached to.
        created_at:
          type: string
          format: date-time
        created_at_ts:
          type: integer
    ErrorResponse:
      title: Error
      type: object
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
          description: Human-readable error description.
        error_code:
          type: integer
          description: >-
            403: access denied (missing / unknown / expired / revoked key, or
            the account is not an active partner: `Error! Access denied`; a
            Read-only key calling a write endpoint: `This API key is
            read-only`). 404: not found. 422: bad request params (message says
            what is wrong). 429: rate limit exceeded (a `Retry-After` header is
            set) or another campaign start is still running. 500: server error.
            503: the platform did not answer a write in time, retry later.
    PixelEvent:
      type: object
      properties:
        event:
          type: string
          enum:
            - smartlink_click
            - new_subscriber
            - new_transaction
            - new_renewal
            - new_dialog
          description: >-
            What happened on the campaign: `new_subscriber` (a fan subscribed),
            `new_transaction` (a fan paid: tip, message, post, subscription,
            stream), `new_renewal` (a renewal: a recurring subscription
            payment), `new_dialog` (a fan sent the model 3 or more messages),
            `smartlink_click` (a click on the tracking link, TikTok pixels
            only).
        platform_event:
          type: string
          nullable: true
          description: >-
            Event name the ad platform receives, for example `Subscribe` or
            `Purchase`. Set per pixel: in Tools -> Pixels or with the pixel
            write endpoints.
  securitySchemes:
    api_key:
      type: apiKey
      name: Authorization
      in: header
      description: >-
        API key from the partner cabinet, Tools -> API
        (https://partners.onlytraffic.com/tools/api): up to 5 named keys per
        account, each Full or Read-only, `ot_partners_` prefix, shown once at
        creation. Raw value or `Bearer` form. Read-only keys cannot call the
        `POST` endpoints (403 `This API key is read-only`); expired or revoked
        keys get 403 `Error! Access denied`.

````

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