A user identity is something that can be used to identify an individual. Most likely, it's an email address, a twitter handle or a phone number. Zendesk supports a series of different such identities.
User identities have the following keys:
| Name | Type | Read-only | Mandatory | Comment |
|---|---|---|---|---|
| id | integer | yes | no | Automatically assigned upon creation |
| url | string | yes | no | The API url of this identity |
| user_id | integer | yes | yes | The id of the user |
| type | string | yes | yes | One of "email", "twitter", "facebook", "google", or "phone_number" |
| value | string | yes | yes | The identifier for this identity, e.g. an email address |
| verified | boolean | no | no | Is true of the identity has gone through verification |
| primary | boolean | no | no | Is true of the primary identity of the user |
| created_at | date | yes | no | The time the identity got created |
| updated_at | date | yes | no | The time the identity got updated |
{
"id": 35436,
"url": "https://company.zendesk.com/api/v2/users/135/identities/35436.json",
"user_id": 135,
"type": "email",
"value": "someone@example.com",
"verified": true,
"primary": true,
"updated_at": "2011-07-20T22:55:29Z",
"created_at": "2011-07-20T22:55:29Z"
}
GET /api/v2/users/{user_id}/identities.json
Returns all user identities for a given user id
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}/identities.json \
-v -u {email_address}:{password}
Status: 200 OK
{
"identities": [
{
"id": 35436,
"user_id": 135,
"type": "email",
"value": "someone@example.com",
"verified": true,
"primary": true,
"updated_at": "2011-07-20T22:55:29Z",
"created_at": "2011-07-20T22:55:29Z"
},
{
"id": 77136,
"user_id": 135,
"type": "twitter",
"value": "didgeridooboy",
"verified": true,
"primary": false,
"updated_at": "2012-02-12T14:25:21Z",
"created_at": "2012-02-12T14:25:21Z"
}
]
}
GET /api/v2/users/{user_id}/identities/{id}.json
Shows the identity with the given id
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}/identities/{id}.json \
-v -u {email_address}:{password}
Status: 200 OK
{
"id": 77938,
"user_id": 13531,
"type": "twitter",
"value": "cabanaboy",
"verified": false,
"primary": false,
"updated_at": "2012-02-12T14:25:21Z",
"created_at": "2012-02-12T14:25:21Z"
}
POST /api/v2/users/{user_id}/identities.json
Add new identities for a given user id. Identities that can be added are:
{ "type" : "email", "value" : "someone@example.com" }{ "type" : "twitter", "value" : "screen_name" }{ "type" : "facebook", "value" : "855769377321" }{ "type" : "google", "value" : "example@gmail.com" }If you need to create an identity without sending out a verification email, pass a "verified": true parameter.
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}/identities.json \
-H "Content-Type: application/json" -X POST \
-d '{"identity": {"type": "email", "value": "foo@bar.com"}}' -v -u {email_address}:{password}
Status: 201 Created
Location: https://{subdomain}.zendesk.com/api/v2/users/135/identities/78138.json
{
"id": 78138,
"user_id": 135,
"type": "twitter",
"value": "cabanaboy",
"verified": false,
"primary": false,
"updated_at": "2012-02-12T14:25:21Z",
"created_at": "2012-02-12T14:25:21Z"
}
PUT /api/v2/users/{user_id}/identities/{id}.json?identity[verified]=true
This API method only allows you to set an identity as verified. You cannot otherwise change value of an identity but must create a new identity and delete the one you're replacing.
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}/identities/{id}.json \
-H "Content-Type: application/json" -X PUT \
-d '{"identity": {"verified": true}}' -v -u {email_address}:{password}
Status: 200 OK
"identity":{
{
"id": 35436,
"user_id": 135,
"type": "email",
"value": "someone@example.com",
"verified": true,
"primary": true,
"updated_at": "2011-07-20T22:55:29Z",
"created_at": "2011-07-20T22:55:29Z"
}
}
PUT /api/v2/users/{user_id}/identities/{id}/make_primary
This API method only allows you to set an identity to primary. If you wish to change an identity, you create a new one with the correct value and delete the old one. This is a collection level operation and the correct behavior for an API client is to subsequently reload the entire collection.
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}/identities/{id}/make_primary.json \
-X PUT -v -u {email_address}:{password} -d ""
Same as List User Identities
PUT /users/{user_id}/identities/{id}/verify
This API method only allows you to set an identity as verified.
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}/identities/{id}/verify.json \
-X PUT -v -u {email_address}:{password} -d ""
Same as Show a User Identity
`PUT /users/{user_id}/identities/{id}/request_verification
This sends a verification email to the user, asking him to click a link in order to verify ownership of the email address
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}/identities/{id}/request_verification.json \
-X PUT -v -u {email_address}:{password} -d ""
Status: 200 OK
DELETE /users/{user_id}/identities/{id}.json
Delete identity for a given user
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}/identities/{id}.json \
-X DELETE -v -u {email_address}:{password}
Status: 200 OK