Syncing Connected Users
How a Connected User record comes into existence, what an external user id is, and how to attach your own name, email and metadata to it.
A Connected User is ByteChef's record of one of your end users. The embedded API has no create endpoint and no bulk import: ByteChef creates the record the first time a request authenticates for that user, and you attach the user's name, email and your own identifiers afterwards with a PATCH request.
This page covers the identity contract, when the record is created, and how to add your own data to it.
The external user id
Every Connected User is keyed by an external user id: an identifier that your application owns and ByteChef stores unchanged. ByteChef never generates or interprets it, so your application is responsible for keeping it unique and stable.
It reaches ByteChef in one of two ways, depending on how the request is authenticated:
| Credential | Where the id comes from |
|---|---|
| Signing Key JWT | The token's sub claim. See Installing the SDK. |
| API Key | The {externalUserId} segment of the request path. |
Both lead to the same lookup, so a user your frontend created through the Connect dialog and a user your backend addresses by path are the same record.
Pick an id that never changes
Use your internal primary key, not an email address or username. Changing the external user id does not rename the Connected User. It creates a second, empty one, and the original user's connections and enabled workflows stay behind on the old id.
The record is created on the first request
The first request that authenticates for a given external user id creates the record, and every later request for that id reuses it. Opening the Connect dialog usually creates it, but any authenticated embedded API call does, including the PATCH request described below.
Signing up a user in your product therefore does not produce a Connected User in ByteChef. To set users up ahead of time (onboarding, a migration, test accounts), an admin creates them in the console instead, one at a time or from a CSV file, and can then provision integrations for them; see Connected Users. A record created there is the same record the SDK later finds: the first authenticated request with that external user id reuses it.
One record per environment
The lookup is scoped to the environment the request carries, so the same external user id in Development and in Production is two independent records, with separate connections, enabled workflows and metadata. Requests select the environment with the optional X-Environment header (DEVELOPMENT, STAGING, PRODUCTION); with the header omitted, ByteChef uses PRODUCTION.
The connected-user API does not copy a user's setup from one environment to another. Each environment's record is built by that environment's own requests.
Attaching your own data
A freshly created record holds only the external user id. To give it a name, an email, or your own fields, PATCH it:
| Endpoint | Credential | Identifies the user by |
|---|---|---|
PATCH /api/embedded/v1/me | Signing Key JWT | the token's sub claim |
PATCH /api/embedded/v1/{externalUserId} | API Key | the path segment |
Use /me from a surface that already holds an end-user JWT, and /{externalUserId} from your backend when you are reconciling users in bulk. Both take a flat JSON object and return 204 No Content.
await fetch(`${baseUrl}/api/embedded/v1/${externalUserId}`, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
'X-Environment': 'PRODUCTION',
},
body: JSON.stringify({
name: 'Ada Lovelace',
email: 'ada@example.com',
plan: 'enterprise',
accountId: 'acct_1234',
}),
});What happens to each key
The body is a free-form object. Keys are handled as follows:
nameandemailbecome record fields. They are matched case-insensitively and are shown as columns in the Connected Users table. This applies only when the value is a string;{"name": 42}is stored as metadata instead.- Everything else becomes metadata, as a string. Metadata values are stored as text, so a number, boolean, or nested object is converted with its string form. Send
{"seats": 5}and you get back"5"; send an object and you get its serialized form rather than a structure you can query. Flatten anything nested yourself, and keep values small. - Metadata is merged, never replaced. Keys you send are added or overwritten; keys you omit are left unchanged.
- You cannot delete a metadata key. Sending
nullfor a key does not clear it: null values are discarded before the merge, so the previous value remains. To represent "unset", write a value your application recognizes, such as an empty string. - An admin edit in the console replaces metadata. Editing a user in the console sets metadata to exactly what the form shows, so it can remove keys. A later PATCH still merges over what the admin saved.
Because authentication creates the record, a PATCH /api/embedded/v1/me with the token of a new user creates the Connected User and then applies the body. Patching a user when they sign up in your product therefore creates their record in that environment before their first connection.
When to call it
Two moments cover most integrations:
- When the user first connects an integration, to set the initial name and email.
- When the profile changes in your product (a rename, a plan change, a new account id), so the Connected Users table and anything that reads metadata stay current.
Because the update is additive, a periodic job that re-sends the profile of each connected user is safe to run. There is no bulk variant; send one request per user.
Disabled users
An admin can disable a Connected User from the console. Until the user is re-enabled, their requests are rejected at authentication, the Connect dialog does not open for them, and their workflows stop running. The record, its connections and its metadata are kept.
See Connected Users for the console side: the table, the detail sheet, and the create, import, edit, enable, disable, and delete actions.
How is this guide?
Last updated on