Create or update a user
Create a user ahead of their first session, or update one, matched by your own id.
Body
idstringrequiredYour own id for this user (1 to 255 characters). Stored as external_id.
namestringDisplay name.
emailstringEmail. Muzekit never emails end users.
localestringEditor language, e.g. en, de.
metadataobjectYour own data, up to 4 KB as JSON; more answers 400 invalid_request.
Request
curl https://api.muzekit.com/v1/users \
-H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{ "id": "user_42", "name": "Ada", "email": "[email protected]" }'const res = await fetch("https://api.muzekit.com/v1/users", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ id: "user_42", name: "Ada", email: "[email protected]" }),
});
const user = await res.json();import os
import requests
# json= sends the body with Content-Type: application/json
user = requests.post(
"https://api.muzekit.com/v1/users",
headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
json={"id": "user_42", "name": "Ada", "email": "[email protected]"},
).json()The user is matched by id in this key's environment. A new id creates the user (and sends the user.created webhook); a known id updates the fields you send and keeps the others. Both answer 201 with the user. You don't need this call before a session: Create a session upserts the user the same way.
Examples
Add a user when they sign up in your app
Call it from your signup handler so the user exists before they first open the editor. You can then upload files into their library or list them in your admin before any session. Keep the returned usr_… id next to your own user.
curl https://api.muzekit.com/v1/users \
-H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: signup-user_42" \
-d '{
"id": "user_42",
"name": "Ada Lovelace",
"email": "[email protected]",
"locale": "en",
"metadata": { "tier": "pro", "company": "Analytical Engines" }
}'// In your signup handler, after you create your own user
const res = await fetch("https://api.muzekit.com/v1/users", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": `signup-${user.id}`,
},
body: JSON.stringify({
id: user.id,
name: user.name,
email: user.email,
locale: user.locale,
metadata: { tier: user.tier },
}),
});
const { id: muzekitUserId } = await res.json(); // "usr_8fK2mQ1xZpR"import os
import requests
# In your signup handler, after you create your own user
res = requests.post(
"https://api.muzekit.com/v1/users",
headers={
"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}",
"Idempotency-Key": f"signup-{user.id}",
},
json={
"id": user.id,
"name": user.name,
"email": user.email,
"locale": user.locale,
"metadata": {"tier": user.tier},
},
)
muzekit_user_id = res.json()["id"] # "usr_8fK2mQ1xZpR"metadata is kept as you send it, for your own use. Muzekit doesn't read it, so it doesn't change what the editor allows. Set per-tier limits on the session instead.
Update a user when their profile changes
Send only the fields that changed. Fields you leave out keep their value. metadata is replaced as a whole, so send the full object, not just the changed key.
curl https://api.muzekit.com/v1/users \
-H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{ "id": "user_42", "locale": "de", "metadata": { "tier": "team" } }'const res = await fetch("https://api.muzekit.com/v1/users", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ id: "user_42", locale: "de", metadata: { tier: "team" } }),
});
const user = await res.json();import os
import requests
user = requests.post(
"https://api.muzekit.com/v1/users",
headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
json={"id": "user_42", "locale": "de", "metadata": {"tier": "team"}},
).json()The new locale sets the editor's language from the user's next session, unless that session passes its own locale.
Import your existing users
Loop over your users once to add them all, for example before you launch the editor. Calls are rate limited to 600 a minute from one address, so a large import should pace itself.
# users.csv: id,name,email (no header row)
while IFS=, read -r id name email; do
curl -s https://api.muzekit.com/v1/users \
-H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
-H "Content-Type: application/json" \
-d "{ \"id\": \"$id\", \"name\": \"$name\", \"email\": \"$email\" }"
sleep 0.2
done < users.csvfor (const u of await db.users.findAll()) {
const res = await fetch("https://api.muzekit.com/v1/users", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ id: String(u.id), name: u.name, email: u.email }),
});
if (!res.ok) console.error(u.id, (await res.json()).error.code);
await new Promise((r) => setTimeout(r, 200)); // stay under the rate limit
}import os
import time
import requests
for u in db.users.all():
res = requests.post(
"https://api.muzekit.com/v1/users",
headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
json={"id": str(u.id), "name": u.name, "email": u.email},
)
if not res.ok:
print(u.id, res.json()["error"]["code"])
time.sleep(0.2) # stay under the rate limitid must be a string, so convert numeric ids. A bad email answers 400 invalid_request with param: "email" for that user only.
Find a user's Muzekit id from your own id
Post just the id to get the user's usr_… id, then read what they made with List templates (?user=usr_…). If the id is new, this creates the user, so use ids from your own user table.
USER=$(curl -s https://api.muzekit.com/v1/users \
-H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{ "id": "user_42" }' | jq -r .id)
curl "https://api.muzekit.com/v1/templates?user=$USER" \
-H "Authorization: Bearer $MUZEKIT_SECRET_KEY"const headers = {
Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}`,
"Content-Type": "application/json",
};
const user = await fetch("https://api.muzekit.com/v1/users", {
method: "POST",
headers,
body: JSON.stringify({ id: "user_42" }),
}).then((r) => r.json());
const designs = await fetch(
`https://api.muzekit.com/v1/templates?user=${user.id}`,
{ headers },
).then((r) => r.json());import os
import requests
headers = {"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"}
user = requests.post(
"https://api.muzekit.com/v1/users",
headers=headers,
json={"id": "user_42"},
).json()
designs = requests.get(
"https://api.muzekit.com/v1/templates",
params={"user": user["id"]},
headers=headers,
).json()Each call also moves the user's last_active_at to now. To avoid that, keep the usr_… id from the first response.
Response
{
"object": "user",
"id": "usr_8fK2mQ1xZpR",
"external_id": "user_42",
"name": "Ada Lovelace",
"email": "[email protected]",
"locale": "en",
"metadata": { "tier": "pro", "company": "Analytical Engines" },
"last_active_at": "2026-10-16T21:35:00.000Z",
"created_at": "2026-10-16T21:35:00.000Z"
}Errors: 400 invalid_request names the field in param (a missing id, a bad email, metadata over 4 KB). See Errors.