Skip to main content

Ads API

Ads endpoints exposed by the Devotel CPaaS API Base path: /api/v1/ads Endpoint count: 15

List custom audiences

GET /api/v1/ads/audiences
Returns the Meta Custom Audiences this workspace has created, each with its linked CDP segment (if any) and last-sync metadata. Read-only; returns an empty list when no audiences exist or no ad account is connected.

List ad campaigns

GET /api/v1/ads/campaigns
Returns the click-to-chat ad campaigns on the connected Meta ad account as a cursor-paginated list. When no ad account is connected the list is empty rather than an error, so the dashboard renders cleanly before setup. Page with the limit and cursor query parameters.

Get an ad campaign with insights

GET /api/v1/ads/campaigns/{id}
Returns one campaign together with a flattened insights summary (impressions, reach, clicks, CTR, spend, CPC, and conversations started) for the campaign details view. The path parameter is the Meta campaign id.
string
required

Get Meta Ads connection status

GET /api/v1/ads/status
Reports whether a Meta ad account is currently connected to this workspace and returns the selected ad_account_id, when it was connected, its billing currency, and the Conversions API state (dataset_id and whether click-to-WhatsApp auto-forwarding is enabled). Poll it to render the ads settings screen and decide whether to start the connect flow. Returns connected: false rather than an error when nothing is linked.

Create a custom audience

POST /api/v1/ads/audiences
Creates a Meta Custom Audience on the connected ad account, optionally linked to a CDP segment so its membership can be synced later. The Meta-assigned audience id and the segment link are stored on the connection. Owner or admin only.

Sync a segment to a custom audience

POST /api/v1/ads/audiences/{audienceId}/sync
Uploads a CDP segment’s current membership to a Meta Custom Audience so it can be targeted (mode add, the default) or suppressed (mode remove) in ads. The segment id comes from the body, falling back to the link recorded when the audience was created. Owner or admin only.
string
required

Create an ad campaign

POST /api/v1/ads/campaigns
Creates a click-to-chat ad campaign on the connected Meta ad account that routes taps into WhatsApp, Messenger, or Instagram Direct. Provide the name, objective, daily budget, destination, ad copy, and optional targeting; the campaign is created PAUSED so you can review it before launching. Owner or admin only.

Connect a Meta ad account

POST /api/v1/ads/connect
Links a Meta (Facebook) ad account to this workspace by storing an OAuth access token and the selected ad account id. Call it once after the user authorizes in Facebook; the token is encrypted at rest and reused by the campaigns, audiences, and Conversions API endpoints. The response warns when no Conversions API dataset id is configured yet. Owner or admin only.

Send a test conversion event

POST /api/v1/ads/conversions/test
Sends a test event to the Meta Conversions API to verify that the connected ad account and its dataset id are wired correctly. Use it after setting a dataset id to confirm CAPI delivery before posting real conversions. Requires a connected account with a dataset id. Owner or admin only.

Exchange a Meta OAuth code for a connection

POST /api/v1/ads/oauth/exchange
Completes the Meta (Facebook) Ads connect flow: exchanges the short-lived OAuth code returned to your redirect URI for a long-lived access token, looks up the authorizing user’s ad accounts, and stores the encrypted token against the first account found. Call it from your OAuth callback page right after the user authorizes in Facebook — you do not need to call /connect separately. Owner or admin only.
string
required
The one-time authorization code Meta appended to your redirect URI.
string
required
The exact HTTPS redirect URI registered with the Meta app and used to obtain the code.

Update an ad campaign

PUT /api/v1/ads/campaigns/{id}
Updates a campaign on the connected Meta ad account — for example to change its status (pause or resume), rename it, or adjust the daily budget. Only the fields you send are changed. Owner or admin only.
string
required

Set the Conversions API dataset

PUT /api/v1/ads/conversions/dataset
Sets or replaces the Meta Conversions API (CAPI) dataset id on the connected ad account so server-side conversion events can be posted. The id is written in place without disturbing the stored access token or ad account id. A dataset id must be set before the test-conversion and conversion-posting endpoints will work. Owner or admin only.

Delete a custom audience

DELETE /api/v1/ads/audiences/{audienceId}
Deletes a Meta Custom Audience at Meta and drops its stored mapping from the connection. This cannot be undone. Owner or admin only. Returns 204 No Content on success.
string
required

Delete an ad campaign

DELETE /api/v1/ads/campaigns/{id}
Permanently deletes a campaign from the connected Meta ad account. This removes the campaign at Meta, not just its local reference, and cannot be undone. Owner or admin only. Returns 204 No Content on success.
string
required

Disconnect the Meta ad account

DELETE /api/v1/ads/disconnect
Removes the stored Meta (Facebook) ad-account connection from this workspace, deleting the encrypted access token and account selection so campaigns, audiences, and the Conversions API stop using it. Call it when the customer switches ad accounts or revokes access; re-run the connect flow to link a new one. Owner or admin only.