# Run multi-client agency operations with Langflow

Source: https://developers.tokportal.com/agents/langflow/agency-multi-client/
Markdown: https://developers.tokportal.com/agents/langflow/agency-multi-client.md

An agency using Langflow with TokPortal runs every client through the same four primitives — bundles, accounts, videos, webhooks — and keeps them separate with `external_ref` and account filters. `create_bundles_bulk` opens a client's fleet in their market, `list_bundles`/`list_accounts` filter by client reference, `videos_only` bundles carry each month's content onto delivered accounts, `create_webhook_endpoint` pushes `account.banned` and `video.finalized` into the agency's tooling, and `export_analytics_videos` / `create_analytics_report` produce the client deliverable. One API key, no per-client OAuth, no app audit, human-operated accounts the agency never has to log into.

## Connect TokPortal to Langflow

Langflow is a workflow / low-code platform: Open-source visual framework for agents; the MCP Tools component connects to servers registered in Settings → MCP Servers.

**Settings → MCP Servers → Add MCP Server** (or the MCP sidebar in the flow editor):

- Mode **HTTP/SSE**: Name `tokportal`, URL `https://app.tokportal.com/api/ext/mcp`, Header `X-API-Key: sk_...`.
- Or mode **JSON**, paste:

```json
{
  "mcpServers": {
    "tokportal": {
      "url": "https://app.tokportal.com/api/ext/mcp",
      "headers": { "X-API-Key": "sk_..." }
    }
  }
}
```

Then drop an **MCP Tools** component into the flow, pick `tokportal`, enable **Tool Mode** and connect it to the Agent component.

Snippet status: **verified** against Langflow's documentation ([source](https://docs.langflow.org/mcp-client)).

Once connected, sanity-check the setup with a read-only call: "What is my TokPortal credit balance?" should trigger `tokportal_get_credit_balance`. GET requests and dry-run writes do not spend credits.

## Try the workflow without spending

For this trial, use the remote MCP endpoint `https://app.tokportal.com/api/ext/mcp`, local `tokportal-mcp` **1.15.1 or later**, or the REST API. Upgrade and restart an older local server first. Version 1.15.0 does not forward the dry-run header; do not use its write tools for a simulation. If you cannot verify the installed local version, use the remote endpoint or REST.

Use the [sandbox](https://developers.tokportal.com/sandbox) for the first attempt. MCP write tools accept `dry_run: true` as a top-level argument, beside `body`; REST writes accept the `X-TokPortal-Dry-Run: true` header. Keep your usual authentication and scopes. Each simulated write validates the request and returns `credits_would_charge` with `credits_charged: 0`. Nothing is created or published.

Simulated IDs start with `00000000-0000-4000-8000-`. Use them only in later dry-run writes. GET requests read real data, so skip publish-readiness checks and polling for synthetic IDs. Simulations have no cross-call memory and upload URLs are placeholders: do not upload files to them.

To run for real, review the returned price and confirm **before the first live write**. Bundle creation charges credits immediately; publishing hands the order to a manager. Repeat creation without dry-run mode and use the new real IDs for configuration and publishing. A synthetic ID cannot be reused in a live request.

## How it works

Structure comes from `external_ref`: put the client slug in it (`acme-us`, `bloom-fr`) on every bundle — `create_bundle` and `create_bundles_bulk` both accept it, and `list_bundles?external_ref=acme-us` returns that client's work. Video slots have their own `external_ref` for creative ids. Accounts inherit their bundle; `list_account_bundles` on an account gives its history. If clients need real isolation, use one API key per client (keys are per workspace, shown once, revocable individually) — the agent can hold several and pick by client.

Monthly operations from Langflow then look like this. Onboarding: `create_bundles_bulk` (`accounts_count`, `videos_per_account`, `country`, warming terms) plus per-account `configure_bundle_account` from the client's brand sheet. Content: `upload_video` for each asset, `batch_configure_bundle_videos` for the month at ≤3/day, `publish_bundle`. Reposting existing accounts next month: `create_bundle` with `bundle_type: videos_only` and `account_id`, `videos_quantity`, then the same batch fill. Corrections: `request_bundle_video_corrections` when the client rejects a post during the 72-hour review (`in_review`), or `finalize_bundle_video` to approve immediately; set `auto_finalize_videos: false` on bundles where the client insists on approving.

Risk and reporting: one webhook endpoint per client system with `account.banned`, `account.ban_appeal.submitted`, `account.ban_resolution.decided`, `video.finalized`; `list_account_bans` as the single source of truth for ban state and refund/remake outcomes; `create_analytics_report` (or `export_analytics_report_html`) for a branded monthly report and `export_analytics_videos` for the raw CSV. Credits are shared per workspace — `list_credit_transactions` gives the per-bundle ledger to re-invoice each client.

## Run it from Langflow

In Langflow the same sequence becomes nodes/steps: either an AI Agent step with the TokPortal tools and the prompt below as its instruction, or one deterministic step per tool. Set `dry_run: true` on MCP write tools, or `X-TokPortal-Dry-Run: true` on HTTP write steps. Map `data.bundle_id` from bundle creation into later simulated write steps; poll only after a real run.

**Tool sequence**

1. `tokportal_get_credit_costs` — Per-client quotes; contract allowances show here.
2. `tokportal_create_bundles_bulk` — Client fleet with `external_ref: <client>`.
3. `tokportal_list_bundles` — `external_ref`, `status`, `platform` filters per client.
4. `tokportal_create_bundle` — `videos_only` + `account_id` for next month's content on delivered accounts.
5. `tokportal_batch_configure_bundle_videos` — Month of slots per bundle.
6. `tokportal_request_bundle_video_corrections` — Client rejects a post in review → manager redoes it.
7. `tokportal_create_webhook_endpoint` — Per-client endpoint: `account.banned`, `account.ban_appeal.submitted`, `account.ban_resolution.decided`, `video.finalized`.
8. `tokportal_list_account_bans` — Ban lifecycle + refund/remake resolution for client comms.
9. `tokportal_create_analytics_report` — Monthly report per client (or `export_analytics_report_html`).
10. `tokportal_list_credit_transactions` — Ledger to re-invoice credits per client.

**Prompt to paste**

```text
Evaluate this workflow in the TokPortal sandbox only.
Use the remote MCP endpoint https://app.tokportal.com/api/ext/mcp or local tokportal-mcp 1.15.1 or later for write tools.
Verify the installed local version before using its write tools. Version 1.15.0 is unsafe for simulations.
If the local version is older or unknown, use the remote endpoint or authenticated REST
requests with X-TokPortal-Dry-Run: true instead.
For every non-GET MCP tool call, set dry_run: true as a top-level boolean beside body.
For every REST write in a workflow, send the X-TokPortal-Dry-Run: true header.
Use normal read tools for existing real objects. Do not GET or poll synthetic IDs,
and do not upload files to simulated upload URLs. Simulated objects have no cross-call memory.
Show credits_would_charge and verify credits_charged is 0 for each simulated write.
Do not execute any live write. Ask for my explicit GO before the first real write,
including bundle creation, which charges immediately. After GO, repeat creation
without dry_run and use the new real IDs; never reuse synthetic IDs in live requests.

Use the TokPortal MCP tools. Client "acme-us": list_bundles with external_ref acme-us and status published,
list_account_bans since 2026-08-01 for their accounts, then create_analytics_report for 2026-08-01 → 2026-08-31
filtered on those accounts. Summarize: posts finalized, views, bans + resolutions, credits spent (list_credit_transactions).
```

Run the flow from the Playground; the Agent component shows each MCP tool call in the trace.

**REST equivalent** (write requests below are simulations; GET requests read existing real data)

```bash
# Client fleet
curl -X POST -H "X-TokPortal-Dry-Run: true" https://app.tokportal.com/api/ext/bundles/bulk \
  -H "X-API-Key: sk_..." -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
  -d '{"platforms":["tiktok"],"country":"US","accounts_count":8,"videos_per_account":30,"external_ref":"acme-us"}'

# This client's bundles
curl "https://app.tokportal.com/api/ext/bundles?external_ref=acme-us&status=published" -H "X-API-Key: sk_..."

# Next month on a delivered account
curl -X POST -H "X-TokPortal-Dry-Run: true" https://app.tokportal.com/api/ext/bundles \
  -H "X-API-Key: sk_..." -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
  -d '{"bundle_type":"videos_only","account_id":"ACCOUNT_UUID","videos_quantity":30,"external_ref":"acme-us","title":"Acme – Oct"}'

# Client-specific ban + delivery webhook
curl -X POST -H "X-TokPortal-Dry-Run: true" https://app.tokportal.com/api/ext/webhooks \
  -H "X-API-Key: sk_..." -H "Content-Type: application/json" \
  -d '{"url":"https://agency.example/hooks/acme","events":["account.banned","account.ban_appeal.submitted","account.ban_resolution.decided","video.finalized"],"description":"Acme"}'
```

## Key parameters

| Parameter                   | Values                                                                                               | Notes                                                       |
| --------------------------- | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| `external_ref`              | ≤200 chars                                                                                           | Client slug on bundles; filter list\_bundles by it.         |
| `bundle_type`               | account\_and\_videos · videos\_only                                                                  | videos\_only + account\_id for recurring content.           |
| `auto_finalize_videos`      | boolean                                                                                              | false when the client must approve each post (72 h window). |
| `status (list_bundles)`     | draft · published · completed …                                                                      | Combine with external\_ref for client dashboards.           |
| `events (webhooks)`         | account.banned · account.ban\_appeal.submitted · account.ban\_resolution.decided · video.finalized … | One endpoint per client system.                             |
| `since (list_account_bans)` | ISO timestamp                                                                                        | Polling watermark on updated\_at.                           |

Full schemas: [OpenAPI reference](https://developers.tokportal.com/api-reference) · [openapi.json](https://developers.tokportal.com/openapi.json).

## Example configurations

**Client onboarding fleet**

```json
{"platforms":["tiktok","instagram"],"country":"FR","accounts_count":6,"videos_per_account":20,
 "wants_advanced_warming":true,"advanced_warming_terms_count":6,"external_ref":"bloom-fr"}
```

**Approval-required content bundle**

```json
{"bundle_type":"videos_only","account_id":"ACCOUNT_UUID","videos_quantity":12,"auto_finalize_videos":false,"external_ref":"bloom-fr"}
```

**Monthly report request**

```json
{"title":"Bloom – September","brandName":"Bloom","from":"2026-09-01","to":"2026-09-30","countries":["FR"],"platforms":["tiktok","instagram"]}
```

## Credits

Credits are shared per workspace; use `list_credit_transactions` (per-bundle lines) to re-invoice each client. Standard rates: 32 per account, 2 per slot, 5 per warming target, 25 per 30 days TokPortal Coverage per eligible account after the included first period. See [Credits & Pricing](https://developers.tokportal.com/credits).

## Why not the official API

Official APIs make an agency the OAuth broker for every client account — each grant expires, each app must be audited, each token is limited to 6 requests/minute with per-user daily caps, and none of it creates or warms accounts. TokPortal gives the agency one key, human-operated accounts per client market, and a ban lifecycle it can actually report on.

As of August 2026 the first-party routes look like this. TikTok's Content Posting API (Direct Post) requires each account owner to authorize your app with the `video.publish` scope, limits every user access token to 6 requests per minute, keeps all posts from unaudited apps in private viewing mode until TikTok audits the app, and enforces an unpublished daily post cap per user (`spam_risk_too_many_posts`) that integrators commonly report at roughly 15–25 posts per account per day. Meta's Instagram Content Publishing API allows 100 API-published posts per professional account in a 24-hour moving window and only for accounts you own and connect via OAuth. Neither creates accounts, warms them, or reports third-party bans. TokPortal is human-operated infrastructure: accounts created and run by managers in the target country, one `X-API-Key` for all of them, dated slots (max 3 per day per bundle) instead of per-account tokens.

Sources: [TikTok Content Posting API – Direct Post](https://developers.tiktok.com/doc/content-posting-api-reference-direct-post), [TikTok Content Posting API – Get started](https://developers.tiktok.com/doc/content-posting-api-get-started), [Instagram Platform – Content Publishing](https://developers.facebook.com/docs/instagram-platform/content-publishing).

## FAQ

### How do I isolate clients?

Lightweight: `external_ref` per bundle and per-client webhook endpoints. Strict: one API key per client (revocable individually) and let the agent pick the key by client.

### Can clients approve posts before they count as done?

Yes — set `auto_finalize_videos: false`; each post waits in `in_review` for `finalize_bundle_video` or `request_bundle_video_corrections` (72-hour window, then auto-finalize).

### What do I tell a client when an account is banned?

Read `list_account_bans` for the exact status (`appeal_pending`, `appeal_refused`, `no_appeal_banned`…) and the staff resolution (`refund`, `remake`, `no_remake` + `reason_code`, `refund_credits`). Never infer bans from other signals.

### How do I produce the monthly deliverable?

`create_analytics_report` (JSON) or `export_analytics_report_html` (branded HTML) with `from`/`to` and country/platform filters, plus `export_analytics_videos` for the CSV appendix.

## Related

- [Agency multi-client playbook](https://developers.tokportal.com/use-cases/industry/agency-multi-client-management)
- [Bans & appeals](https://developers.tokportal.com/bans-and-appeals)
- [Webhooks](https://developers.tokportal.com/webhooks)
- [Analytics API](https://developers.tokportal.com/analytics)
- [MCP server](https://developers.tokportal.com/mcp)

## Also works with

- [Run multi-client agency operations with CrewAI](https://developers.tokportal.com/agents/crewai/agency-multi-client)
- [Run multi-client agency operations with LangChain](https://developers.tokportal.com/agents/langchain/agency-multi-client)
- [Run multi-client agency operations with Vercel AI SDK](https://developers.tokportal.com/agents/vercel-ai-sdk/agency-multi-client)
- [Run multi-client agency operations with Mastra](https://developers.tokportal.com/agents/mastra/agency-multi-client)
- [Run multi-client agency operations with Claude](https://developers.tokportal.com/agents/claude/agency-multi-client)
- [Run multi-client agency operations with Claude Code](https://developers.tokportal.com/agents/claude-code/agency-multi-client)

[All 25 agents for "Run multi-client agency operations"](https://developers.tokportal.com/agents/for/agency-multi-client)

## Other jobs with Langflow

- [Create TikTok accounts with Langflow](https://developers.tokportal.com/agents/langflow/create-tiktok-accounts)
- [Post 100 TikTok videos a day with Langflow](https://developers.tokportal.com/agents/langflow/post-100-videos-a-day)
- [Run US TikTok accounts from abroad with Langflow](https://developers.tokportal.com/agents/langflow/us-tiktok-accounts-from-abroad)
- [Warm TikTok & Instagram accounts with Langflow](https://developers.tokportal.com/agents/langflow/warm-accounts)
- [Run a faceless TikTok channel with Langflow](https://developers.tokportal.com/agents/langflow/faceless-channel)
- [Seed UGC across many accounts with Langflow](https://developers.tokportal.com/agents/langflow/ugc-seeding)
- [Seed a music sound on TikTok with Langflow](https://developers.tokportal.com/agents/langflow/music-sound-seeding)
- [Launch an app with persona accounts with Langflow](https://developers.tokportal.com/agents/langflow/app-persona-launch)
- [Get ban alerts via webhooks with Langflow](https://developers.tokportal.com/agents/langflow/ban-webhooks)
- [Pull analytics across all accounts with Langflow](https://developers.tokportal.com/agents/langflow/analytics-multi-account)
- [Create Instagram accounts with Langflow](https://developers.tokportal.com/agents/langflow/create-instagram-accounts)
