> ## 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.

# Создать пиксель

> 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.

То же, что **Add pixel** в **Tools -> Pixels**. В ответе приходит новый `pixel_id`: передайте его в [привязку](https://onlytraffic.com/docs/ru/partners/api/campaign-pixel-attach.md), чтобы поставить пиксель на кампанию. Пока пиксель не привязан, он ничего не отправляет.

## Что передавать

| Поле | Обязательно | Что это |
| - | - | - |
| `platform` | Да | `facebook` (Meta Ads) или `tiktok` (TikTok Ads). Потом изменить нельзя |
| `platform_pixel_id` | Да | Pixel ID (Dataset ID) из Meta Events Manager или Pixel Code из TikTok Events Manager |
| `access_token` | Да | Токен Conversions API (Meta) или Events API (TikTok) |
| `pixel_name` | Нет | Ваша подпись для пикселя |
| `test_event_code` | Нет | Код из инструмента Test Events платформы. Задайте его для первой проверки и уберите до запуска рекламы |
| `event_source_url` | Нет | Только Meta: адрес вашего собственного лендинга. Адрес на onlyfans.com не подходит |
| `events` | Нет | Маппинг событий. Не передавайте, чтобы получить значения по умолчанию |

Где взять Pixel ID и токен, по шагам показано в статье [Пиксели рекламных платформ](https://onlytraffic.com/docs/ru/partners/revshare-pixels.md).

## Токен доступа

Токен только записывается. Он хранится в зашифрованном виде, ни один метод его не возвращает, и в журнал запросов API он не попадает. Чтобы заменить токен, передайте новый в [изменении пикселя](https://onlytraffic.com/docs/ru/partners/api/pixel-update.md).

## События

Если не передавать `events`, пиксель получит значения платформы по умолчанию:

| Событие | Когда срабатывает | Meta | TikTok |
| - | - | - | - |
| `smartlink_click` | Посетитель кликнул по трекинговой ссылке | Недоступно | `ViewContent` |
| `new_subscriber` | Фанат подписался | `Subscribe` | `Subscribe` |
| `new_transaction` | Фанат заплатил: подписка, чаевые, платное сообщение или пост, стрим | `Purchase` | `CompletePayment` |
| `new_renewal` | Продление подписки (повторное списание) | `Purchase` | `CompletePayment` |
| `new_dialog` | Фанат отправил модели 3 и более сообщений | `Lead` | `Contact` |

Чтобы выбрать самим, передайте `events`. Список задаёт весь маппинг целиком: событие, которого в нём нет, отключено.

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

В этом примере продления уходят в Meta как `Subscribe`, остальные платежи как `Purchase`, а диалоги не отправляются. На неверное название придёт ответ со списком допустимых.

## После сохранения

Мы отправляем на платформу одну проверку с вашим токеном. Результат появляется в `health` в течение минуты: прочитайте [список пикселей](https://onlytraffic.com/docs/ru/partners/api/pixels.md) или посмотрите [проверку пикселя](https://onlytraffic.com/docs/ru/partners/api/pixel-check.md). Пиксель TikTok проверяется, только если у него задан тестовый код.

У аккаунта может быть до 50 активных пикселей.

## Ошибки

| Сообщение | Значение |
| - | - |
| `Incorrect platform: facebook \| tiktok` | `platform` не передан или неизвестен (`422`) |
| `platform_pixel_id is required`, `access_token is required` | Не передано обязательное поле (`422`) |
| `Incorrect events: array of {event, platform_event}` | `events` не является списком пар (`422`) |
| `Unknown event: …`, `Unknown platform event for …` | Такого названия у платформы нет. В сообщении перечислены допустимые (`422`) |
| `Enable at least one event` | `events` передан пустым списком (`422`) |
| `Event Source URL: enter a valid domain, e.g. https://yourdomain.com` | `event_source_url` не является адресом (`422`) |
| `Meta blocks onlyfans.com as an event source: use your own landing page domain, or leave the field empty` | `event_source_url` ведёт на onlyfans.com (`422`) |
| `… is too long: N characters max` | Поле длиннее допустимого (`422`) |
| `Pixel limit reached (50). Archive unused pixels first` | У аккаунта уже 50 активных пикселей (`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.