Pug keeps a profile for every user your project tracks, identified or anonymous, holding the traits you set and linked to the user’s events.
| Service | Auth | What it does |
|---|---|---|
sdk.profiles.v1.ProfilesSDKService |
x-api-key: public or private key |
Write: Identify, BatchIdentify |
shared.profiles.v1.ProfilesService |
Private key (prv_...) or dashboard JWT |
Read and erase: Get, GetByExternalId, List, Delete, DeleteDataSubject, GetDeletionRequest |
See Authentication and the auth matrix for key types and headers.
ProfilesSDKService: write path
POST /sdk.profiles.v1.ProfilesSDKService/IdentifyCreates or updates the profile for externalId. Traits are shallow-merged into an existing profile’s: the keys you send overwrite stored values, and other keys are left as they are.
Auth for both methods: an x-api-key header holding a public key (pub_...) or a private key (prv_...). The key identifies the project, so no Authorization or x-project-id header is needed.
IdentifyRequest fields
| Proto field | JSON name | Type | Required | Notes |
|---|---|---|---|---|
external_id |
externalId |
string | Yes | Stable, unique user identifier: your database user ID, not an email, which can change. Must be non-empty and must not start with cookieless- (reserved) |
traits |
traits |
google.protobuf.Struct |
No | Plain JSON, shallow-merged into stored traits; on a conflict these win |
anonymous_id |
anonymousId |
string | No | The distinctId the user’s anonymous events carried, to merge them. Empty or starting with anon-; at most 255 characters |
device_id |
deviceId |
string | No | A push device registered through sdk.devices.v1, to link to this profile; at most 36 characters, and an unregistered ID is ignored. The Flutter SDK sends one and the Android and iOS SDKs don’t; omit it for web |
traits type: plain JSON, not PropertyValue
traits is a google.protobuf.Struct, a plain JSON object: pass bare values, not the { "stringValue": "..." } wrappers that event properties use. A wrapped value is stored as a nested object.
{
"traits": {
"email": "user@example.com",
"plan": "pro",
"seats": 5,
"trial": false
}
}A top-level $ip trait is dropped. A trait key or string holding a NUL character (\u0000) can’t be stored: the identify is accepted but never applied.
anonymous_id constraint
Any value other than "" or an anon--prefixed ID fails with invalid_argument, so anonymous events can be merged only if their distinctId starts with anon-. The Web SDK’s anonymous IDs do.
Anonymous to identified merge
An identify merges a user’s prior anonymous activity only when it carries their anonymousId, so send it on the first identify after an anonymous session. The merge moves that ID’s events, properties and devices to the identified profile and soft-deletes the anonymous one. Identifying the same anonymousId under another external ID later moves all of its history to that user, so start a new anonymous ID after sign-out. There is no alias() method.
IdentifyResponse
The response is {}. The identify is applied asynchronously, so a read straight after it may not see it yet, and two identifies for one user sent close together can apply in either order.
Wire example
curl -X POST https://api.pugs.dev/sdk.profiles.v1.ProfilesSDKService/Identify \
-H "Content-Type: application/json" \
-H "Connect-Protocol-Version: 1" \
-H "x-api-key: pub_..." \
-d '{
"externalId": "user-123",
"anonymousId": "anon-abc456",
"traits": {
"email": "user@example.com",
"plan": "pro",
"company": "Acme Inc"
}
}'BatchIdentify
POST /sdk.profiles.v1.ProfilesSDKService/BatchIdentifyAdded in server v0.0.48. Takes up to 1000 identifies, each validated as Identify validates it, so one invalid item fails the whole request before any is queued.
{
"identifies": [
{ "externalId": "user-123", "anonymousId": "anon-abc456", "traits": { "plan": "pro" } },
{ "externalId": "user-456", "traits": { "plan": "free" } }
]
}The response is { "accepted": 2 }, the number of items queued, not yet applied. Within one request, items for one externalId that only set traits are merged in order, later values winning per key, unless the merged identify would pass 900 KiB. An item carrying anonymousId or deviceId isn’t merged into earlier ones, so it can apply before them. The request isn’t atomic: it can fail after queueing some items, and a retry queues those again, overwriting anything newer.
ProfilesService: read and manage
Auth: a private key (prv_...) in x-api-key, or a dashboard JWT in Authorization: Bearer. A public key gets unauthenticated.
x-api-key: prv_...
# -- or --
Authorization: Bearer <jwt>Methods
| Method | Endpoint |
|---|---|
Get |
POST /shared.profiles.v1.ProfilesService/Get |
GetByExternalId |
POST /shared.profiles.v1.ProfilesService/GetByExternalId |
List |
POST /shared.profiles.v1.ProfilesService/List |
Delete |
POST /shared.profiles.v1.ProfilesService/Delete |
DeleteDataSubject |
POST /shared.profiles.v1.ProfilesService/DeleteDataSubject |
GetDeletionRequest |
POST /shared.profiles.v1.ProfilesService/GetDeletionRequest |
Get
Fetch a profile by its Pug ID.
Request
| Field | Type | Required | Notes |
|---|---|---|---|
id |
string | Yes | A profile ID, as List and GetByExternalId return it. An anonymous person’s is its distinctId, though a cookieless one is never found; an anonymous ID merged by Identify returns the profile it joined |
include_bots |
bool | No | JSON includeBots. Include traffic tagged as a bot at ingest: count it in activity, and find an anonymous person whose traffic is all bot-tagged. Defaults to false |
{ "id": "dbolnlavh7ldv7r89na0" }Response: a Profile.
{
"profile": {
"id": "dbolnlavh7ldv7r89na0",
"externalId": "user-123",
"properties": { "email": "user@example.com", "plan": "pro" },
"projectId": "dbolnlavh7ldv7r89nag",
"createTime": "2026-01-15T10:00:00Z",
"updateTime": "2026-06-01T14:30:00Z",
"activity": {
"firstSeen": "2026-01-15T10:00:00Z",
"lastSeen": "2026-06-01T14:30:00Z",
"totalEvents": "342",
"pageviews": "198",
"sessions": "27",
"browser": "Google Chrome",
"os": "macOS",
"country": "US"
}
}
}GetByExternalId
Fetch a profile by the externalId you passed to Identify.
Request
| Field | Type | Required | Notes |
|---|---|---|---|
external_id |
string | Yes | The externalId set on Identify |
include_bots |
bool | No | JSON includeBots. As on Get |
{ "externalId": "user-123" }Response: same shape as Get.
List
Streams every matching profile in one call, up to 100 per frame, newest first. List is server-streaming, so plain JSON gets HTTP 415: send Content-Type: application/connect+json and frame the request and each response message in a 5-byte envelope (a flags byte, then the message length as a big-endian uint32), or use a generated Connect client. The final frame, flagged 0x02, carries any error, auth failures included, under HTTP 200.
Request
| Field | JSON name | Type | Notes |
|---|---|---|---|
page_token |
pageToken |
string | A frame’s nextPageToken, to resume after that frame. Empty (or omitted) to start |
filter_groups |
filterGroups |
FilterGroup[] |
Each group has filters (at least one PropertyFilter) and an operator (LOGICAL_OPERATOR_AND or LOGICAL_OPERATOR_OR) to combine them |
filter_groups_operator |
filterGroupsOperator |
LogicalOperator |
Combines the groups. Defaults to LOGICAL_OPERATOR_AND |
include_bots |
includeBots |
bool | As on Get; identified profiles are listed either way. Keep it the same for a whole pageToken run - flipping it mid-run skips rows |
sort |
sort |
ProfileListSort |
PROFILE_LIST_SORT_CREATE_TIME (the default), PROFILE_LIST_SORT_FIRST_SEEN or PROFILE_LIST_SORT_LAST_SEEN, newest first. A pageToken works only with the sort it came from |
A PropertyFilter has property, operator (one of the filter operators), value or values, and source. With source unset or PROPERTY_SOURCE_PROFILE, property is a trait key of ASCII letters, digits, _ and -, such as "plan", or a dot path into a nested trait; with PROPERTY_SOURCE_AUTO it is one of $browser, $browserVersion, $os, $osVersion, $device, $country, $region or $city, matched against the profile’s activity.
Example - filter by plan
{
"filterGroups": [
{
"filters": [
{ "property": "plan", "operator": "FILTER_OPERATOR_EQUALS", "value": "pro" }
],
"operator": "LOGICAL_OPERATOR_AND"
}
]
}Response (each frame)
{
"profiles": [ { "id": "...", "externalId": "user-123", "properties": { "plan": "pro" }, "...": "..." } ],
"nextPageToken": "eyJzIjoiY3JlYXRlX3RpbWUiLCJ0IjoiMjAyNi0wNi0wMVQxNDozMDowMFoiLCJpIjoiZGJvbG5sYXZoN2xkdjdyODluYTAifQ"
}The last frame carries no nextPageToken. To resume an interrupted stream, send the last token you received as pageToken. A person whose sort time changes mid-run can be skipped or returned twice.
Delete
Erases a person: soft-deletes the profile and deactivates its push devices at once, then queues irreversible deletion of the person’s events, activity, devices and profile, which a worker carries out. They leave reads when it finishes. On a dashboard JWT, erasing needs the member or admin role.
Request
| Field | Type | Required | Notes |
|---|---|---|---|
id |
string | Yes | A profile ID, an external ID, or any distinctId that has events, cookieless ones included. An anonymous ID merged by Identify erases the profile it joined |
{ "id": "dbolnlavh7ldv7r89na0" }Response: the erasure request, such as { "requestId": "dbolnlavh7ldv7r89nb0", "status": "COMPLIANCE_REQUEST_STATUS_PENDING" }, to follow with GetDeletionRequest. Calling Delete again before that request completes returns the same request, and re-queues it if it failed.
DeleteDataSubject
Erases the person with an external ID, as Delete does. It goes ahead when no profile has that ID, erasing the events that carry it as their distinctId.
Request
| Field | Type | Required | Notes |
|---|---|---|---|
external_id |
string | Yes | JSON externalId. The externalId set on Identify; "" gets not_found |
{ "externalId": "user-123" }Response: as for Delete, including a repeated call.
GetDeletionRequest
Reports an erasure request’s progress.
Request
| Field | Type | Required | Notes |
|---|---|---|---|
request_id |
string | Yes | JSON requestId, as Delete or DeleteDataSubject returned it |
{ "requestId": "dbolnlavh7ldv7r89nb0" }Response
| Proto field | JSON name | Type | Notes |
|---|---|---|---|
request_id |
requestId |
string | The erasure request’s ID |
external_id |
externalId |
string | The erased external ID, when known |
profile_id |
profileId |
string | The erased profile’s ID, or the anonymous distinctId, when known |
status |
status |
ComplianceRequestStatus |
COMPLIANCE_REQUEST_STATUS_PENDING, then _PROCESSING, then _COMPLETED or _FAILED |
events_identified |
eventsIdentified |
int64, as a JSON string | Events found to erase when processing began, not a count of rows removed; "0" until then |
requested_at |
requestedAt |
RFC 3339 timestamp | When the erasure was requested |
completed_at |
completedAt |
RFC 3339 timestamp | Set once COMPLETED |
error |
error |
string | Why it failed, when FAILED |
To retry a FAILED request, repeat the call that created it.
Profile message
Returned by Get, GetByExternalId, and each frame of List.
| Proto field | JSON name | Type | Notes |
|---|---|---|---|
id |
id |
string | Pug profile ID; an anonymous person’s is its distinctId |
external_id |
externalId |
string | Set via Identify; empty for an anonymous person |
properties |
properties |
google.protobuf.Struct |
Traits, as plain JSON (same encoding as IdentifyRequest.traits); empty for an anonymous person |
project_id |
projectId |
string | Project this profile belongs to |
create_time |
createTime |
RFC 3339 timestamp | First identify; an anonymous person’s first event |
update_time |
updateTime |
RFC 3339 timestamp | Latest identify; an anonymous person’s latest event |
activity |
activity |
ProfileActivitySummary |
Absent when the profile has no events |
ProfileActivitySummary fields
| Proto field | JSON name | Type | Notes |
|---|---|---|---|
first_seen |
firstSeen |
RFC 3339 timestamp | Earliest event |
last_seen |
lastSeen |
RFC 3339 timestamp | Latest event |
total_events |
totalEvents |
int64, as a JSON string | All events attributed to this profile |
pageviews |
pageviews |
int64, as a JSON string | page_view events |
sessions |
sessions |
int64, as a JSON string | Session count |
browser |
browser |
string | Browser name |
browser_version |
browserVersion |
string | Browser version |
os |
os |
string | Operating system name |
os_version |
osVersion |
string | OS version |
device |
device |
string | Device type or model |
country |
country |
string | ISO 3166-1 alpha-2 country code |
region |
region |
string | Region / state |
city |
city |
string | City name |
bot |
bot |
bool | true when every event counted here was tagged as a bot at ingest, so only ever with include_bots |
The string fields take their value from the latest event. Activity is computed from the person’s events, so it trails both ingestion and identify merges.
Errors
| Code | HTTP | Cause |
|---|---|---|
unauthenticated |
401 | Missing, malformed, or expired credential, or a public key on ProfilesService |
permission_denied |
403 | JWT only: the caller isn’t in the project’s org, or their role doesn’t permit the call |
invalid_argument |
400 | A field broke a rule on this page, or an identify is too large to queue (about 1 MiB) |
not_found |
404 | No profile with the given id or externalId, or no erasure request with the given requestId |
resource_exhausted |
429 | Request body over 8 MiB, measured after decompression |
internal |
500 | Server error: retry with exponential backoff |
unavailable |
503 | The key couldn’t be checked: retry with exponential backoff |
List reports these in its final frame.
Further reading
- HTTP transport: calling
Identifywithout an SDK - Authentication: public vs. private keys, key rotation
- Auto-properties:
$-prefixed properties set by the server on events - Events API:
PropertyValue-wrapped properties used byBatchCreate