curl --request POST \
  --url https://api.frigade.com/v1/public/users \
  --header 'Authorization: Bearer <token>'

The users endpoint allows you to create users, add events, and update user properties. The endpoint is especially useful for bootstrapping your user data in Frigade so that you can target Flows based on user properties and events.

Creating users in Frigade

Frigade will create a user for any foreignId that is sent to the users endpoint, which does not already exist. If the user already exists, the user will be updated with the new properties and events.

If you wish to create a user without any properties, you can simply call the endpoint with the foreignId:

curl -i -X POST \
   -H "Authorization:Bearer api_public_J3FNG3dJASDKLW98SN4KLOJHNTYUFGNVSK" \
   -H "Content-Type:application/json" \
   -d \
'{
  "foreignId":"MyUserId"
}' \
 'https://api.frigade.com/v1/public/users'

Add events to a user

curl -i -X POST \
   -H "Authorization:Bearer api_public_J3FNG3dJASDKLW98SN4KLOJHNTYUFGNVSK" \
   -H "Content-Type:application/json" \
   -d \
'{
  "foreignId":"MyUserId",
  "events": [
    {
      "event": "ProjectCreation",
      "properties": {
        "hasCreatedProject": true
      }
    }
  ]
}' \
 'https://api.frigade.com/v1/public/users'

Update user properties

curl -i -X POST \
   -H "Authorization:Bearer api_public_J3FNG3dJASDKLW98SN4KLOJHNTYUFGNVSK" \
   -H "Content-Type:application/json" \
   -d \
'{
  "foreignId":"MyUserId",
  "properties": {
    "hasCreatedProject": true
  }
}' \
 'https://api.frigade.com/v1/public/users'

Getting a user by foreignId

To fetch a user, you can use the GET /v1/users endpoint. As this endpoint returns PII, you will need to use the private API key. You should not use this endpoint in your frontend code, as it will expose your private API key.

curl -i -X GET \
   -H "Authorization:Bearer api_private_t3YtBqLJuOeFzIElTYBARERMQljitCgy7mhusWthcEHKCMpEU4LrQmuhd4RRAawi" \
 'https://api.frigade.com/v1/users?foreignId=some-other-user'
{
  "name": "John Doe",
  "foreignId": "my-user-id",
  "createdAt": "2023-08-02T14:58:17.275Z",
  "modifiedAt": "2023-08-02T14:58:17.275Z",
  "slug": "user_vkBjCGzEjRT1INHq",
  "properties":{
    "company": "CoolCo"
  }
}