Create a new Signing Key for the account making the request

POST /v1/Keys

API keys

Create a new Signing Key for the account making the request.

application/x-www-form-urlencoded

Body

  • AccountSid string Required

    The SID of the Account that created the Payments resource.

    Minimum length is 34, maximum length is 34. Format should match the following pattern: ^AC[0-9a-fA-F]{32}$.

  • FriendlyName string

    A descriptive string that you create to describe the resource. It can be up to 64 characters long.

  • KeyType string

    The `KeyType` form parameter is used to specify the type of key you want to create.

    Default Behavior: If `KeyType` is not specified, the API will generate a standard key.

    Restricted Key: If `KeyType` is set to `restricted`, the API will create a new restricted key. In this case, a policy object is required to define the permissions.

    Value is restricted.

  • Policy

    The `Policy` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the Twilio documentation.

Responses

  • 201 application/json

    Created

    Hide headers attributes Show headers attributes
    • Access-Control-Allow-Origin string

      Specify the origin(s) allowed to access the resource

    • Access-Control-Allow-Methods string

      Specify the HTTP methods allowed when accessing the resource

    • Access-Control-Allow-Headers string

      Specify the headers allowed when accessing the resource

    • Access-Control-Allow-Credentials boolean

      Indicates whether the browser should include credentials

    • Access-Control-Expose-Headers string

      Headers exposed to the client

    Hide response attributes Show response attributes object
    • sid string | null

      The unique string that that we created to identify the NewKey resource. You will use this as the basic-auth user when authenticating to the API.

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^SK[0-9a-fA-F]{32}$.

    • friendly_name string | null

      The string that you assigned to describe the resource.

    • date_created string(date-time-rfc-2822) | null

      The date and time in GMT that the API Key was created specified in RFC 2822 format.

    • date_updated string(date-time-rfc-2822) | null

      The date and time in GMT that the new API Key was last updated specified in RFC 2822 format.

    • secret string | null

      The secret your application uses to sign Access Tokens and to authenticate to the REST API (you will use this as the basic-auth password). Note that for security reasons, this field is ONLY returned when the API Key is first created.

    • policy object | null

      Collection of allow assertions.

POST /v1/Keys
curl \
 --request POST 'https://iam.twilio.com/v1/Keys' \
 --user "username:password" \
 --header "Content-Type: application/x-www-form-urlencoded" \
 --data 'AccountSid=ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&FriendlyName=foo'
Request examples
{"AccountSid" => "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "FriendlyName" => "foo"}
{"Policy" => "{\"allow\":[\"/twilio/messaging/messages/read\"]}", "KeyType" => "restricted", "AccountSid" => "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "FriendlyName" => "foo"}
Response examples (201)
{
  "sid": "SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "policy": null,
  "secret": "foobar",
  "date_created": "Mon, 13 Jun 2016 22:50:08 +0000",
  "date_updated": "Mon, 13 Jun 2016 22:50:08 +0000",
  "friendly_name": "foo"
}
{
  "sid": "SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "policy": {
    "allow": [
      "/twilio/messaging/messages/read"
    ]
  },
  "secret": "foobar",
  "date_created": "Mon, 13 Jun 2016 22:50:08 +0000",
  "date_updated": "Mon, 13 Jun 2016 22:50:08 +0000",
  "friendly_name": "foo"
}