Menu

API Keys

Your application, mail client, or website can all use API (Application Programming Interface) keys to authenticate access to SendGrid services. You can revoke an API key at any time without having to change your username and password, and an API key can be scoped to perform a limited number of actions.

There are 3 different types of API keys:

  • Full Access
    Allows the API key to access GET, PATCH, PUT, DELETE and POST endpoints for all parts of your account, excluding billing and Email Address Validation.
  • Restricted Access
    Customizes levels of access for all parts of your account, excluding billing and Email Address Validation.
  • Billing Access
    Allows the API key to access billing endpoints for the account.

You must create your first API key using the Twilio SendGrid App. Once you have a key with permissions to manage other keys, you can use the endpoints documented as part of this API.

Update API key name and scopes

Update API key name and scopes

PUT /api_keys/{api_key_id}

This endpoint allows you to update the name and scopes of a given API key.

You must pass this endpoint a JSON request body with a name field and a scopes array containing at least one scope. The name and scopes fields will be used to update the key associated with the api_key_id in the request URL.

If you need to update a key's scopes only, pass the name field with the key's existing name; the name will not be modified. If you need to update a key's name only, use the "Update API key name" endpoint.

See the API Key Permissions List for all available scopes.

Authentication

  • API Key

Headers

Authorization
string
default: Bearer <<YOUR_API_KEY_HERE>>
required
on-behalf-of
string
default: The subuser's username. This header generates the API call as if the subuser account was making the call.

Request Body

object
name
string
required
scopes
array[string]
{
  "name": "Profiles key",
  "scopes": [
    "user.profile.read",
    "user.profile.update"
  ]
}

Path Parameters

api_key_id
string
default: None
required

Responses

object
scopes
array[string]

The permissions this API Key has access to.

api_key_id
string

The ID of your API Key.

name
string

The name of your API Key.

{
  "api_key_id": "qfTQ6KG0QBiwWdJ0-pCLCA",
  "name": "Mail Send",
  "scopes": [
    "mail.send",
    "mail.batch.create",
    "mail.batch.read",
    "mail.batch.update",
    "mail.batch.delete",
    "user.scheduled_sends.create",
    "user.scheduled_sends.read",
    "user.scheduled_sends.update",
    "user.scheduled_sends.delete",
    "sender_verification_eligible",
    "sender_verification_legacy",
    "2fa_required"
  ]
}
object
errors
array[object]
message
string

the error message

field
string or null

the field that generated the error

help
object

helper text or docs for troubleshooting

id
string
{
  "errors": [
    {
      "field": "field_name",
      "message": "error message"
    }
  ]
}
object
errors
array[object]
message
string

the error message

field
string or null

the field that generated the error

help
object

helper text or docs for troubleshooting

id
string
{
  "errors": [
    {
      "field": "field_name",
      "message": "error message"
    }
  ]
}
object
errors
array[object]
message
string

the error message

field
string or null

the field that generated the error

help
object

helper text or docs for troubleshooting

id
string
{
  "errors": [
    {
      "field": "field_name",
      "message": "error message"
    }
  ]
}
object
errors
array[object]
message
string

the error message

field
string or null

the field that generated the error

help
object

helper text or docs for troubleshooting

id
string
{
  "errors": [
    {
      "field": "field_name",
      "message": "error message"
    }
  ]
}
object
errors
array[object]
message
string
Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the SendGrid tag on Stack Overflow.

Thank you for your feedback!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Sending your feedback...
🎉 Thank you for your feedback!
Something went wrong. Please try again.

Thanks for your feedback!

Refer us and get $10 in 3 simple steps!

Step 1

Get link

Get a free personal referral link here

Step 2

Give $10

Your user signs up and upgrade using link

Step 3

Get $10

1,250 free SMSes
OR 1,000 free voice mins
OR 12,000 chats
OR more