Source: https://developers.tokportal.com/use-cases/no-code/zapier-social-media-automation/
Markdown: https://developers.tokportal.com/use-cases/no-code/zapier-social-media-automation.md

# TokPortal + Zapier

TokPortal does not currently provide a native Zapier app. Use **Webhooks by Zapier** with the public REST API.

The API can create bundles, configure account profiles, configure videos from public URLs, publish bundles, and read status/analytics. Zapier handles the trigger and data mapping; TokPortal handles the order lifecycle after publish.

## Authentication

Add these headers to every Webhooks action:

| Header         | Value              |
| -------------- | ------------------ |
| `X-API-Key`    | `sk_your_key_here` |
| `Content-Type` | `application/json` |

Put TokPortal API keys in `X-API-Key`, not in the bearer authorization header.

## Example Zap: Google Sheets to TikTok bundle

Sheet columns:

```text
country,username,visible_name,biography,profile_picture_url,video_url,description,target_publish_date
```

`country` is a code from `GET /countries`. Most are ISO alpha-2 (`FR`, `DE`, `BR`), but the United States is `USA` and the United Kingdom is `UK`; the aliases `US` and `GB` are accepted and resolved to those. A country name such as `United States` fails with `INVALID_COUNTRY`. `target_publish_date` is `YYYY-MM-DD` and cannot be earlier than today + 3 days while the account is still being created, or today + 1 once it is delivered or when the bundle runs on an existing account. A bundle accepts at most 3 videos per day.

### 1. Trigger

Use **Google Sheets > New Spreadsheet Row** or any equivalent app trigger.

### 2. Create bundle

Action: **Webhooks by Zapier > Custom Request**

```text
Method: POST
URL: https://app.tokportal.com/api/ext/bundles
Headers:
  X-API-Key: sk_your_key_here
  Content-Type: application/json
Body:
{
  "bundle_type": "account_and_videos",
  "platform": "tiktok",
  "country": "{{country}}",
  "videos_quantity": 1,
  "external_ref": "zapier-{{zap_meta_human_now}}"
}
```

Zapier should map `data.bundle_id` from the response into later actions.

Reference: [Create Bundle](https://developers.tokportal.com/create-bundle)

### 3. Configure account

```text
Method: PUT
URL: https://app.tokportal.com/api/ext/bundles/{{data.bundle_id}}/account
Headers:
  X-API-Key: sk_your_key_here
  Content-Type: application/json
Body:
{
  "username": "{{username}}",
  "visible_name": "{{visible_name}}",
  "biography": "{{biography}}",
  "profile_picture_url": "{{profile_picture_url}}"
}
```

Reference: [Account Configuration](https://developers.tokportal.com/account-configuration)

### 4. Configure video

```text
Method: PUT
URL: https://app.tokportal.com/api/ext/bundles/{{data.bundle_id}}/videos/1
Headers:
  X-API-Key: sk_your_key_here
  Content-Type: application/json
Body:
{
  "video_type": "video",
  "description": "{{description}}",
  "target_publish_date": "{{target_publish_date}}",
  "video_url": "{{video_url}}"
}
```

`video_url` can be a public/direct URL or a `public_url` returned by [Media Upload](https://developers.tokportal.com/media-upload). If your Zap receives a large binary file, use a public URL or presigned upload flow instead of sending the file through Zapier.

Reference: [Configure Videos](https://developers.tokportal.com/configure-videos)

### 5. Publish

```text
Method: POST
URL: https://app.tokportal.com/api/ext/bundles/{{data.bundle_id}}/publish
Headers:
  X-API-Key: sk_your_key_here
```

Reference: [Publish & Unpublish](https://developers.tokportal.com/publish-unpublish)

## Useful Zap patterns

| Trigger App | Pattern                                       |
| ----------- | --------------------------------------------- |
| Airtable    | New approved content brief creates a bundle   |
| Dropbox     | New shared video URL configures a video slot  |
| Shopify     | New product launch creates a content workflow |
| Slack       | Slash command triggers a prefilled bundle     |
| Webhooks    | Your CMS posts campaign payloads into Zapier  |

## Monitoring

For reliable production workflows, add one of these:

- Poll `GET /bundles/{id}` until the status changes.
- Use [TokPortal webhooks](https://developers.tokportal.com/webhooks) to send lifecycle events to a Zapier Catch Hook.
- Pull [Analytics](https://developers.tokportal.com/analytics) only after the delivered account has live posts.

Related guides: [n8n](https://developers.tokportal.com/use-cases/no-code/n8n-tiktok-automation), [Make](https://developers.tokportal.com/use-cases/no-code/make-tiktok-automation), [Python Quickstart](https://developers.tokportal.com/use-cases/platform-guides/python-quickstart).
