> Documentation index: https://docs.zernio.com/llms.txt. Every page is also Markdown: add .md to its URL.

# Profiles

Create a profile, connect accounts into it (several of the same platform if you like), move accounts between profiles, and rename or delete it later.

A profile groups connected accounts: one per brand, client or customer. Every team starts with a profile named "Default", and profiles are free.

## Create a profile

Call `POST /v1/profiles` with a unique `name`, or create it in the [dashboard](https://zernio.com/dashboard). `externalId` tags it with your own id, such as a customer id when you [build a platform](/multi-tenant).

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
import Zernio from '@zernio/node';

const zernio = new Zernio();

const { data: created } = await zernio.profiles.createProfile({
  body: { name: 'Second brand', color: '#4CAF50' },
});

const profileId = created.profile._id;
```
</Tab>
<Tab value="Python">
```python
from zernio import Zernio

client = Zernio()

created = client.profiles.create_profile(name="Second brand", color="#4CAF50")

profile_id = created["profile"]["_id"]
```
</Tab>
<Tab value="curl">
```bash
curl -X POST "https://zernio.com/api/v1/profiles" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Second brand", "color": "#4CAF50" }'
```
</Tab>
</Tabs>

```json
{ "profile": { "_id": "66a1f0c2a4b9d3e8f1a2b3c4", "name": "Second brand", "externalId": null, "isDefault": false } }
```

## Connect an account into it

Call `GET /v1/connect/{platform}` with the `profileId` and send the user to the returned `authUrl`. Repeat it to add more accounts of the same platform.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
const { data: connect } = await zernio.connect.getConnectUrl({
  path: { platform: 'tiktok' },
  query: { profileId, redirect_url: 'https://your-app.com/callback' },
});

console.log(connect.authUrl);
```
</Tab>
<Tab value="Python">
```python
connect = client.connect.get_connect_url(
    platform="tiktok",
    profile_id=profile_id,
    redirect_url="https://your-app.com/callback",
)

print(connect["authUrl"])
```
</Tab>
<Tab value="curl">
```bash
curl "https://zernio.com/api/v1/connect/tiktok?profileId=66a1f0c2a4b9d3e8f1a2b3c4&redirect_url=https://your-app.com/callback" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```
</Tab>
</Tabs>

The user comes back to your `redirect_url` with `accountId` and `username` in the query string. Headless mode and the Page selection step are in [connecting accounts](/guides/connecting-accounts).

## Find an account in a profile

Call `GET /v1/accounts` with `profileId` and `platform`, and match on `username`: a profile can hold several accounts of one platform.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
const { data: listed } = await zernio.accounts.listAccounts({
  query: { profileId, platform: 'tiktok' },
});

const accountId = listed.accounts.find((account) => account.username === 'secondbrand')?._id;
```
</Tab>
<Tab value="Python">
```python
listed = client.accounts.list_accounts(profile_id=profile_id, platform="tiktok")

account_id = next(a["_id"] for a in listed["accounts"] if a["username"] == "secondbrand")
```
</Tab>
<Tab value="curl">
```bash
curl "https://zernio.com/api/v1/accounts?profileId=66a1f0c2a4b9d3e8f1a2b3c4&platform=tiktok" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```
</Tab>
</Tabs>

`accounts[]._id` is the `accountId` you pass in `platforms[]` on `POST /v1/posts`.

## Move an account to another profile

Call `PATCH /v1/accounts/{accountId}` with `{ "profileId": "<target profile id>" }`. The account keeps its id, posts and analytics, and its linked ad accounts move with it.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
await zernio.accounts.moveAccountToProfile({
  path: { accountId },
  body: { profileId: otherProfileId },
});
```
</Tab>
<Tab value="Python">
```python
client.accounts.move_account_to_profile(account_id=account_id, profile_id=other_profile_id)
```
</Tab>
<Tab value="curl">
```bash
curl -X PATCH "https://zernio.com/api/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "profileId": "66a1f0c2a4b9d3e8f1a2b3c5" }'
```
</Tab>
</Tabs>

## List, update or delete profiles

| Request | What it does |
|---|---|
| `GET /v1/profiles` | Lists profiles, default first. Filters: exact `name`, `externalId` (`GET /v1/profiles?externalId=` finds a customer's profile). Paging: `limit`, `skip`. |
| `PUT /v1/profiles/{profileId}` | Changes `name`, `description`, `color`, `externalId` (`null` clears it) and `isDefault`. |
| `DELETE /v1/profiles/{profileId}` | Deletes it for good. Disconnect its active accounts first. |

## How it behaves

- **Several accounts per platform.** A profile holds any number of accounts, including three Instagram accounts or five Facebook Pages.
- **Reconnecting refreshes.** Connecting an account the profile already has updates it instead of adding a copy. `reconnectAccountId` targets one account.
- **One ad account per ads platform** per profile (one Meta ad account, one Google Ads account).
- **Billing counts accounts, not profiles.** 10 profiles with 1 account each cost the same as 1 profile with 10 ([pricing](/pricing/social#what-counts-as-a-connected-account)).
- **Deleting moves leftovers.** Disconnected accounts and WhatsApp numbers in a deleted profile move to another of your profiles.
- **Retries.** Send an `Idempotency-Key` header on `POST /v1/profiles` if your client retries ([idempotency](/guides/idempotency)).

## If it fails

| Error | Cause | Fix |
|---|---|---|
| `403` on `POST /v1/profiles` | A legacy Stripe or AppSumo plan's profile cap is full. No `type` or `code`: branch on the status and `details.resource`. | Delete an unused profile or move to usage-based billing (no cap). |
| `409` on create | A profile with that `name` exists. | Use `details.existingProfileId` or pick another name. |
| `409` with `code: "profile_external_id_conflict"` | Another profile has that `externalId` (`param: "externalId"`). | Use the existing profile or a new `externalId`. |
| `409` `idempotency_conflict` | The same `Idempotency-Key` is still in flight. | Retry after the first request completes. |
| `409` on move | The target profile has that account, or an ad account of the same ads platform. | Move to another profile or disconnect the duplicate. |
| `400` on delete | The profile still has an active connected account. | Disconnect its accounts first. |

## Related

- [Create profile](/profiles/create-profile), [List profiles](/profiles/list-profiles), [Delete profile](/profiles/delete-profile)
- [Start OAuth](/connect/get-connect-url) and [List accounts](/accounts/list-accounts)
- [Move account to another profile](/accounts/move-account-to-profile)
- [Build a platform](/multi-tenant): one profile per customer