# TikTok

The `tiktok` provider node uses a selected TikTok creator connection. It has
one required `input` socket and one `output` socket. The input is an execution
dependency; operation values are configured under `operation`.

Use the nested operation form:

```json
{
  "connection": "<connection-id>",
  "operation": { "op": "get_profile" }
}
```

The connection must be a TikTok connection. Text fields are interpolatable.

`retry` (default Off) sends a request again after a failure that passes; see
[Retries](http_get.md#retries). `get_profile` and the chunk transfers of
`upload_to_inbox` are sent again freely. `list_videos`, `query_videos`,
`get_post_status` and the upload initialization are sent as `POST`, so they
are sent again only when TikTok refused them before acting: the connection
never opened, or TikTok answered 425 or 429.

## Operations

### `get_profile`

```json
{ "operation": { "op": "get_profile" } }
```

Returns `{ "operation": "get_profile", "creator": ... }`. The creator
snapshot includes identity/profile fields, optional fields when TikTok
provides them, `metrics`, and one `as_of` timestamp. Metrics are a snapshot
from this execution, not historical TikTok analytics.

### `list_videos`

```json
{
  "operation": {
    "op": "list_videos",
    "max_count": "20",
    "cursor": ""
  }
}
```

`max_count` is an integer from 1 to 20. `cursor` is an optional non-negative
TikTok cursor; pass the returned cursor for the next page. Output is:
`{ operation, videos, cursor?, has_more, count }`. Videos are public videos
available through Display API, and their counters are point-in-time snapshots.

### `query_videos`

```json
{
  "operation": {
    "op": "query_videos",
    "video_ids": "video-id-1,video-id-2"
  }
}
```

`video_ids` is comma- or newline-separated, with 1–20 unique IDs. This is a
known-ID query, not arbitrary search or research. Output preserves matched
video order and reports IDs TikTok did not return:
`{ operation, videos, missing_video_ids, count }`.

### `upload_to_inbox`

```json
{
  "operation": {
    "op": "upload_to_inbox",
    "media": "{\"object_id\":\"<object-id>\"}"
  }
}
```

`media` resolves to inline binary, `{ "binary": ..., "filename": "...",
"content_type": "..." }`, or a durable `{ "object_id": "..." }`
reference. The inline object's `content_type` overrides the binary MIME type;
`filename` is accepted as binary metadata but isn't used to override the
TikTok upload contract. A durable reference uses its stored bytes and
metadata, including its stored content type and filename; no filename or
content-type override is supported for durable references. The service validates non-empty media, supported
container/MIME mapping, size, and chunk planning before initialization.
TikTok's documented maximum, 5 MiB minimum regular chunk, 64 MiB maximum
chunk, and chunk-count limits apply. Files up to 64 MiB use one chunk; larger
files use 32 MiB chunks with the final chunk absorbing the remainder.

Output is `{ operation, publish_id, state: "transferred", transferred_at,
bytes_transferred, requires_creator_action: true }`. It means the bytes were
transferred to the creator's inbox, not that a post was published. Upload
URLs and media bytes are never output or persisted. If initialization or a
chunk may have been accepted before failure, the result is ambiguous: don't
retry the upload automatically; call `get_post_status`.

Current provider limits are five pending inbox shares per rolling 24 hours and
six posting initializations per minute per user access token. Provider
responses are authoritative if TikTok changes these limits.

### `get_post_status`

```json
{
  "operation": {
    "op": "get_post_status",
    "publish_id": "<publish-id>"
  }
}
```

Performs one status read and returns `{ operation, publish_id, state,
provider_status?, fail_reason?, uploaded_bytes?, post_ids }`. Normalized
states are `processing`, `sent_to_inbox`, `published`, `failed`, and `unknown`.
`published` can appear only after the creator completes the action in TikTok;
an upload transfer never emits it. Compose any polling with workflow control
nodes. Post IDs are strings so large provider IDs retain their precision.

## Boundaries

Missing provider fields remain absent or null; they aren't converted to zero.
The node does not read comment bodies, reply to or moderate comments, provide
analytics, search arbitrary public content, trigger from TikTok webhooks,
publish directly, or provide Research, Marketing, Shop, or advertising APIs.
