Skip to contentSkip to navigationSkip to topbar
On this page

Access Token Resource


Your client side application uses the AccessToken resource to authenticate its request to the Verify Push API when creating (i.e., enrolling or registering) an Entity and/or Factor.

(information)

Info

While this Verify Push AccessToken resource is similar to those used by Twilio voice/chat/video products, it cannot be reused between them.


AccessToken Properties

accesstoken-properties page anchor
Property nameTypeRequiredDescriptionChild properties
sidSID<YK>Optional
Not PII

A 34 character string that uniquely identifies this Access Token.

Pattern: ^YK[0-9a-fA-F]{32}$Min length: 34Max length: 34

account_sidSID<AC>Optional

The unique SID identifier of the Account.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

service_sidSID<VA>Optional

The unique SID identifier of the Verify Service.

Pattern: ^VA[0-9a-fA-F]{32}$Min length: 34Max length: 34

entity_identitystringOptional

The unique external identifier for the Entity of the Service.


factor_typeenum<string>Optional

The Type of the Factor. Currently only push is supported.

Possible values:
push

factor_friendly_namestringOptional
PII MTL: 30 days

A human readable description of this factor, up to 64 characters. For a push factor, this can be the device's name.


tokenstringOptional

The access token generated for enrollment, this is an encrypted json web token.


urlstring<uri>Optional

The URL of this resource.


ttlintegerOptional

How long, in seconds, the access token is valid. Max: 5 minutes

Default: 0


Create an AccessToken resource

create-an-accesstoken-resource page anchor
POST https://verify.twilio.com/v2/Services/{ServiceSid}/AccessTokens

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
ServiceSidSID<VA>required

The unique SID identifier of the Service.

Pattern: ^VA[0-9a-fA-F]{32}$Min length: 34Max length: 34
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
Identitystringrequired

The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, and generated by your external system, such as your user's UUID, GUID, or SID.


FactorTypeenum<string>required

The Type of this Factor. Eg. push

Possible values:
push

FactorFriendlyNamestringOptional

The friendly name of the factor that is going to be created with this access token


TtlintegerOptional

How long, in seconds, the access token is valid. Can be an integer between 60 and 300. Default is 60.

Create an AccessTokenLink to code sample: Create an AccessToken
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createAccessToken() {
11
const accessToken = await client.verify.v2
12
.services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.accessTokens.create({
14
factorType: "push",
15
identity: "Identity",
16
});
17
18
console.log(accessToken.sid);
19
}
20
21
createAccessToken();

Output

1
{
2
"sid": "YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"entity_identity": "ff483d1ff591898a9942916050d2ca3f",
6
"factor_type": "push",
7
"factor_friendly_name": "John Doe iPhone",
8
"ttl": 300,
9
"date_created": "2015-07-30T20:00:00Z",
10
"token": "eyJ6aXAiOiJERUYiLCJraWQiOiJTQVNfUzNfX19LTVNfdjEiLCJjdHkiOiJ0d2lsaW8tZnBhO3Y9MSIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJkaXIifQ..qjltWfIgQaTwp2De.81Z_6W4kR-hdlAUvJQCbwS8CQ7QAoFRkOvNMoySEj8zEB4BAY3MXhPARfaK4Lnr4YceA2cXEmrzPKQ7bPm0XZMGYm1fqLYzAR8YAqUetI9WEdQLFytg1h4XnJnXhgd99eNXsLkpKHhsCnFkchV9eGpRrdrfB0STR5Xq0fdakomb98iuIFt1XtP0_iqxvxQZKe1O4035XhK_ELVwQBz_qdI77XRZBFM0REAzlnEOe61nOcQxkaIM9Qel9L7RPhcndcCPFAyYjxo6Ri5c4vOnszLDiHmeK9Ep9fRE5-Oz0px0ZEg_FgTUEPFPo2OHQj076H1plJnFr-qPINDJkUL_i7loqG1IlapOi1JSlflPH-Ebj4hhpBdMIcs-OX7jhqzmVqkIKWkpPyPEmfvY2-eA5Zpoo08YpqAJ3G1l_xEcHl28Ijkefj1mdb6E8POx41skAwXCpdfIbzWzV_VjFpmwhacS3JZNt9C4hVG4Yp-RGPEl1C7aJHRIUavAmoRHaXbfG20zzv5Zu0P5PcopDszzoqVfZpzc.GCt35DWTurtP-QaIL5aBSQ",
11
"url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AccessTokens/YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
12
}

Fetch an AccessToken resource

fetch-an-accesstoken-resource page anchor
GET https://verify.twilio.com/v2/Services/{ServiceSid}/AccessTokens/{Sid}

Property nameTypeRequiredPIIDescription
ServiceSidSID<VA>required

The unique SID identifier of the Service.

Pattern: ^VA[0-9a-fA-F]{32}$Min length: 34Max length: 34

SidSID<YK>required

A 34 character string that uniquely identifies this Access Token.

Pattern: ^YK[0-9a-fA-F]{32}$Min length: 34Max length: 34
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchAccessToken() {
11
const accessToken = await client.verify.v2
12
.services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.accessTokens("YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.fetch();
15
16
console.log(accessToken.sid);
17
}
18
19
fetchAccessToken();

Output

1
{
2
"sid": "YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"entity_identity": "ff483d1ff591898a9942916050d2ca3f",
6
"factor_type": "push",
7
"factor_friendly_name": "John Doe iPhone",
8
"ttl": 60,
9
"date_created": "2015-07-30T20:00:00Z",
10
"token": "eyJ6aXAiOiJERUYiLCJraWQiOiJTQVNfUzNfX19LTVNfdjEiLCJjdHkiOiJ0d2lsaW8tZnBhO3Y9MSIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJkaXIifQ..qjltWfIgQaTwp2De.81Z_6W4kR-hdlAUvJQCbwS8CQ7QAoFRkOvNMoySEj8zEB4BAY3MXhPARfaK4Lnr4YceA2cXEmrzPKQ7bPm0XZMGYm1fqLYzAR8YAqUetI9WEdQLFytg1h4XnJnXhgd99eNXsLkpKHhsCnFkchV9eGpRrdrfB0STR5Xq0fdakomb98iuIFt1XtP0_iqxvxQZKe1O4035XhK_ELVwQBz_qdI77XRZBFM0REAzlnEOe61nOcQxkaIM9Qel9L7RPhcndcCPFAyYjxo6Ri5c4vOnszLDiHmeK9Ep9fRE5-Oz0px0ZEg_FgTUEPFPo2OHQj076H1plJnFr-qPINDJkUL_i7loqG1IlapOi1JSlflPH-Ebj4hhpBdMIcs-OX7jhqzmVqkIKWkpPyPEmfvY2-eA5Zpoo08YpqAJ3G1l_xEcHl28Ijkefj1mdb6E8POx41skAwXCpdfIbzWzV_VjFpmwhacS3JZNt9C4hVG4Yp-RGPEl1C7aJHRIUavAmoRHaXbfG20zzv5Zu0P5PcopDszzoqVfZpzc.GCt35DWTurtP-QaIL5aBSQ",
11
"url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AccessTokens/YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
12
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.