# Airtable to TikTok: n8n template for approved videos

This n8n workflow posts each Airtable record whose Status is Approved to one TikTok account through PubNio as a public video, the only privacy level PubNio admits for TikTok. The record's Disclosure and AI generated fields become TikTok settings. The record keeps a saved idempotency key, so rerunning after a timeout never posts the video twice.

Download: <https://pubnio.com/templates/n8n/airtable-to-tiktok.json> (n8n workflow JSON, no credentials inside). Checked on n8n 2.50.7. Destination: TikTok (Live).

## What it does

- **Trigger.** A Schedule Trigger every 15 minutes searches the table with `{Status} = 'Approved'`.
- **Approval.** Set the record's Status to Approved. The Airtable search only returns Approved records, and the workflow checks again before sending.
- **Request.** One create request per approved item. Each create carries the item's saved key as `Idempotency-Key`, and every request sends `PubNio-Version: 2026-12-02`.
- **Result.** The answer is written back to the item; the next runs read the post's status until every destination settles.

## Fields: Airtable fields

| Field | Type | Use |
| --- | --- | --- |
| `Status` | single select | Approved sends the record. |
| `Caption` | long text | The TikTok caption. |
| `Video URL` | URL | A public HTTPS MP4. |
| `Disclosure` | single select | none, own_brand, or paid_partnership; empty means none. |
| `AI generated` | checkbox | Labels the video as AI-generated. |

The workflow also fills `pubnio_key`, `pubnio_post_id`, `pubnio_status`, `pubnio_outcome`, `pubnio_error`, `pubnio_sent_at`; create them as text fields.

## Set up

1. **Create a PubNio API key.** In PubNio, create an API key with the publish scope; it includes read, which the status checks use.
2. **Import the workflow.** Download the JSON and import it into n8n with Import from File. It is checked on n8n 2.50.7.
3. **Add the PubNio credential.** Create a Header Auth credential named PubNio API key with name Authorization and value Bearer followed by the key. Select it on **Create post in PubNio**, **Read post status**, **Import media**, **Read media status**.
4. **Fill PubNio settings.** Open the PubNio settings node and set `workspaceId`, `tiktokAccountId`. `tiktokAccountId`: The TikTok account ID from PubNio's list of connected accounts.
5. **Connect Airtable.** Add the airtable fields above and the pubnio_ text fields, then select your Airtable credential and the same base and table on **Read rows**, **Save key before sending**, **Write result to row**.
6. **Run one approved test item.** Approve one test item, run the workflow once, and read pubnio_status and pubnio_outcome. Then activate it.

## Request

Every video is sent as `PUBLIC_TO_EVERYONE`: PubNio's TikTok check rejects any other privacy level with `tiktok_privacy_unsupported`. PubNio does not post this network's media from a URL, so the workflow first has PubNio import Video URL, waits for the import to be ready, and sends the media ID it returns.

```json
{
  "text": "Three ways to fold a jacket",
  "media": [
    {
      "mediaId": "bbbbbbbb-2222-4bbb-8bbb-bbbbbbbbbbbb"
    }
  ],
  "targets": [
    {
      "accountId": "77777777-7777-4777-8777-777777777777",
      "settings": {
        "privacy": "PUBLIC_TO_EVERYONE",
        "commercialDisclosure": "own_brand",
        "isAiGenerated": true
      }
    }
  ]
}
```

## Tested behavior

The download is imported unchanged into a clean n8n 2.50.7 container, and its node types, versions, parameters, and operations are checked against that release. Then a copy runs with n8n execute. Its PubNio requests and its Code, If, Switch, and Merge nodes run as published. Its trigger and source nodes are simulated by a fake source with the same row shapes, its media wait is cut to one second, and PubNio is a fake API that decodes every request with PubNio's own schemas and checks it with PubNio's own content rules. PubNio's test suite replays every create and validate request the run sent against the real API and requires the same answer. It proves:

- Only approved items are sent to PubNio.
- The key is a hash of the stable row ID, saved on the row with its send time before the request that sends it.
- A lost response (503 after PubNio admitted the post) is resent with the same key and PubNio returns the first post.
- A key with no post ID that was sent 23 hours and 1 minute ago, or has no send time, stops at needs_review instead of being resent.
- A 202 is recorded as queued or scheduled, never as published, until a delivery reports it.
- Every record is sent with `privacy: "PUBLIC_TO_EVERYONE"`; Disclosure and AI generated arrive as `commercialDisclosure` and `isAiGenerated`, and an empty Disclosure as `none`.
- Video URL is imported and sent as `media[0].mediaId`; a record without a video is rejected with `media_required at targets.0.media`, then accepted once the URL is filled.

## Recovery

- **When pubnio_error starts `Media import failed`:** PubNio could not fetch Video URL. Point it at a public HTTPS file, clear pubnio_status, and the next run imports it again.
- **When pubnio_status is `media_processing`:** Nothing to do: PubNio is still importing the file, and the next run checks the same import again.
- **When the delivery `failed` with `tiktok_processing_failed`:** TikTok could not process the video; re-encode it and add a new record.

## Limits

- One TikTok account per workflow.
- Public videos only: PubNio publishes TikTok posts as `PUBLIC_TO_EVERYONE`, so there is no private or friends-only option.
- Video posts only; photo posts need a different body.
- PubNio has no approval step of its own; approval happens in Airtable before n8n calls PubNio.
- The check uses a fake PubNio and fake provider answers, so this page shows no real delivery.

## Related

- [n8n integration: every PubNio template](https://pubnio.com/integrations/n8n)
- [Airtable to Pinterest: n8n template that pins approved records](https://pubnio.com/templates/n8n/airtable-to-pinterest)
- [Airtable to a Facebook Page queue: n8n template](https://pubnio.com/templates/n8n/airtable-to-facebook)
- [PubNio quickstart](https://pubnio.com/docs/quickstart/)

