# Update Audience — TikTok Ads Manager

> Update a TikTok custom audience — rename it, or add/remove/replace members via a file of hashed identifiers. To rename only, provide audience_name and omit identifiers/file_path. To modify members, provide identifiers or file_path and set…

- Key: `tiktok_ads_manager-update-audience`
- Type: Action (Write)
- Version: 0.0.2
- App: TikTok Ads Manager (`tiktok_ads_manager`) — https://pipedream.com/apps/tiktok-ads-manager.md
- This page (HTML): https://pipedream.com/apps/tiktok-ads-manager/actions/update-audience
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/tiktok_ads_manager/actions/update-audience/update-audience.mjs

## Description

Update a TikTok custom audience — rename it, or add/remove/replace members via a file of hashed identifiers. To rename only, provide `audience_name` and omit `identifiers`/`file_path`. To modify members, provide `identifiers` or `file_path` and set `action` (`APPEND`, `REMOVE`, or `REPLACE`). The file upload and audience update happen in one tool call. Audience size must remain ≥ 1,000 after the operation. Use **List Audiences** to find the `audience_id`. [See the documentation](https://business-api.tiktok.com/portal/docs/update-an-audience/v1.3)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `advertiserId` | `string` | Yes | Your TikTok Ads Manager advertiser ID. Find it in the Ads Manager URL after aadvid= (e.g., aadvid=7123456789012345678). Also visible under Account Info in Business Center. |
| `audienceId` | `string` | Yes | ID of the custom audience to update. Use List Audiences to find the ID. |
| `audienceName` | `string` | No | New display name for the audience (max 128 characters). Required if identifiers and file_path are both omitted. |
| `action` | `string` | No | How to modify audience members. APPEND adds new identifiers. REMOVE removes matching identifiers. REPLACE replaces all members. Required when providing identifiers or file_path. Default: REPLACE. |
| `calculateType` | `string` | No | Hash type of the identifiers in the upload. Must match the type used when the audience was created. |
| `identifiers` | `string[]` | No | List of SHA256-hashed identifiers to add/remove/replace. Pass these directly instead of a file. Example: ["a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3"]. |
| `filePath` | `string` | No | CSV/text file with one SHA256-hashed identifier per line. Use identifiers instead if you have the values inline. |
| `syncDir` | `dir` | No | SyncDir |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "tiktok_ads_manager",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "tiktok_ads_manager-update-audience",
  arguments: {
    advertiserId: "Advertiser ID",
    audienceId: "Audience ID",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "tiktok_ads_manager-update-audience",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    tiktok_ads_manager: { authProvisionId: "apn_xxxxxxx" },
    advertiserId: "Advertiser ID",
    audienceId: "Audience ID",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "tiktok_ads_manager-update-audience",
    "configured_props": {
      "tiktok_ads_manager": { "authProvisionId": "apn_xxxxxxx" },
      "advertiserId": "Advertiser ID",
      "audienceId": "Audience ID"
    }
  }'
```

---

- App: https://pipedream.com/apps/tiktok-ads-manager.md · All apps: https://pipedream.com/apps
