Update traits
curl --request PUT \
--url https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"player_key": "<string>",
"user_id": "<string>",
"traits": {},
"set": [
"<string>"
],
"deleted": [
"<string>"
],
"updated_at": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}Players API
Update Traits
Merge-update the traits of one identified player. Set a Discord ID, Steam ID, email, socials or any custom trait, or send null to delete a trait, in one PUT request.
PUT
/
v0
/
projects
/
{projectId}
/
players
/
{playerKey}
/
traits
Update traits
curl --request PUT \
--url https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.manalens.dev/v0/projects/{projectId}/players/{playerKey}/traits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"player_key": "<string>",
"user_id": "<string>",
"traits": {},
"set": [
"<string>"
],
"deleted": [
"<string>"
],
"updated_at": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
],
"refused": [
{
"index": 0,
"message_id": "<string>",
"code": "<string>",
"message": "<string>"
}
],
"results": [
{
"index": 0,
"user_id": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
],
"feature": "<string>",
"billing_url": "<string>"
}
}Sets and deletes traits on the profile of one identified player. Traits are the data that describes a player; event data stays “properties”. Keys that you do not send keep their values. The response returns the merged traits, so you do not need a second read.
This endpoint writes user traits only, so an
Known traits such as
Reports, the Players page, and
To unlink, send
Authentication
Use an API key (mana_api_...) with the profiles:write scope. See Authentication.
- The key works on its own project only. Another project’s key gets
404. - The key’s creator must be an owner, admin or editor.
- Call it from a server. A request with a browser
Originheader gets403.
Path parameters
| Parameter | Rule |
|---|---|
projectId | The project ID |
playerKey | user:<user_id>, where user_id is the ID that you send with identify (1 to 255 characters). URL-encode the whole key, for example user%3Aplayer_42. |
anon: key gets 400: identify the player first. Anonymous traits come from a traits event without a user_id. If no profile exists for the user_id, the write creates it.
Body
A flat object of traits. Send 1 to 50 keys, at most 8 KB as JSON. The whole body is at most 16 KB.| Rule | Value |
|---|---|
| Key | Starts with a letter, then letters, digits, _, . or -. At most 100 characters. |
| Value | A string (at most 1024 characters), a number, a boolean, or null |
null | Deletes the trait |
| Reserved keys | user_id (it is the profile key, so it cannot be set or unset here) |
| Reserved value | The string _is_deleted (an internal marker). Send null to delete. |
discord_id and steam_id must be strings and pass a light format check. Any other key is a custom trait.
This endpoint is a trusted channel, so it can set the protected traits (email, itch_user_id, stripe_customer_id and paddle_customer_id). A game or website cannot set them.
{
"discord_id": "112233445566778899",
"display_name": "Luca",
"twitter": null,
"level": 12
}
Response
200:
{
"player_key": "user:player_42",
"user_id": "player_42",
"traits": {
"discord_id": "112233445566778899",
"display_name": "Luca",
"level": 12,
"supporter": true
},
"set": ["discord_id", "display_name", "level"],
"deleted": ["twitter"],
"updated_at": "2026-11-15T12:00:00.000Z"
}
| Field | Notes |
|---|---|
traits | The user traits after this write: the traits read before the write, with this update merged in |
set, deleted | The keys that this request set and deleted |
updated_at | The time of the write |
GET reads show the write after a few seconds.
Delete a trait
Sendnull. Set and delete can go in the same request:
curl -sS -X PUT \
-H "Authorization: Bearer $MANALENS_PROJECT_KEY" \
-H "Content-Type: application/json" \
-d '{ "discord_id": "112233445566778899", "twitter": null }' \
"https://api.manalens.dev/v0/projects/$PROJECT_ID/players/user%3Aplayer_42/traits"
Link a Discord account
A Discord bot or your website links a player to a Discord account with one call:await fetch(`${API}/v0/projects/${projectId}/players/${encodeURIComponent(`user:${userId}`)}/traits`, {
method: 'PUT',
headers: { authorization: `Bearer ${process.env.MANALENS_PROJECT_KEY}`, 'content-type': 'application/json' },
body: JSON.stringify({ discord_id: interaction.user.id, discord: interaction.user.username }),
});
{ "discord_id": null, "discord": null }. Keep the key in server-side secrets.
Errors
| Status | Code | Meaning |
|---|---|---|
400 | INVALID_TRAITS | A key, a value, or the playerKey failed validation (for example, it does not start with user:). The message names the key, never the value. Nothing is written. |
401 | UNAUTHORIZED | The key is missing, unknown or revoked |
402 | SUBSCRIPTION_REQUIRED | The workspace has no active subscription or trial |
402 | PLAN_UPGRADE_REQUIRED | The workspace is on Indie or the Launch Pass. Player traits need the Studio plan. |
403 | FORBIDDEN | The key has no profiles:write scope, its creator is below editor, or the request came from a browser |
403 | WORKSPACE_SUSPENDED | The workspace is suspended. API keys of a suspended workspace get no access. |
404 | NOT_FOUND | The key belongs to another project |
413 | TOO_LARGE | The body is larger than 16 KB |
429 | TOO_MANY_REQUESTS | The key or workspace budget is used up. Wait for Retry-After. |
429 | RATE_LIMITED | The project sent too many server events and trait writes this minute |
PUT is idempotent: you can retry the same body after a 429 or a 5xx.Authorizations
Path Parameters
Body
application/json
Response
The player traits after the write