Get

Retrieve a list of all credentials, or permissions for a specific credential.

Parameters

Parameter Required Requirements Description
api_user Yes alphanumeric The primary account holder’s user ID creating the new account
api_key Yes alphanumeric The primary account holder’s password
username No alphanumeric If a username is supplied, the API returns the JSON permissions for that user

Call

1
https://sendgrid.com/api/credentials/get.json?api_user=sendgrid_username&api_key=sendgrid_password

Response: Success

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[
  {
    "id": 4,
    "name": "johnsmith",
    "permissions": {
      "email": 0,
      "api": 1
    }
  },
  {
    "id": 15,
    "name": "joewrigley",
    "permissions": {
      "web": 1,
      "api": 0
    }
  }
]

Response: Error

1
2
3
{
  "error": "error reason"
}

Call

1
https://sendgrid.com/api/credentials/get.xml?api_user=sendgrid_username&api_key=sendgrid_password

Response: Success

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?xml version="1.0" encoding="ISO-8859-1"?>

<credentials>
   <credential>
      <created_at>2013-01-21 16:52:01</created_at>
      <permissions>
         {"web": 1, "api": 0, "email": 0}
         <permissions>
            <id>13243</id>
            <name>John Smith</name>
            <updated_at>2013-01-21 16:52:01</updated_at>
         </permissions>
         <credential>
            <created_at>2013-01-21 16:52:01</created_at>
            <permissions>
               {"web": 1, "api": 1, "email": 0}
               <permissions>
                  <id>13243</id>
                  <name>Joe Wrigley</name>
                  <updated_at>2013-01-21 16:52:01</updated_at>
               </permissions>
            </permissions>
         </credential>
      </permissions>
   </credential>
</credentials>

Response: Error

1
2
3
4
5
<?xml version="1.0" encoding="ISO-8859-1"?>

<result>
   <message>error: reason</message>
</result>

Add

This API call allows user to add a new set of credentials to their account.

Parameters

Parameter Required Requirements Description
api_user Yes alphanumeric The primary account holder’s user ID creating the new account
api_key Yes alphanumeric The primary account holder’s password
username Yes alphanumeric Enter a username for the new account
password Yes alphanumeric Enter a password for the new account
permissions No JSON array of bits

Credentials are specified using a JSON object. There are three key names: email for access to SMTP, api for programmatic access, and web for administration. The values for each are a bit, 0 for off or 1 for on.

The following example allows the specified username/password to log into the dashboard, but not send email or have access to any of the APIs:

{"email": 0, "web": 1, "api": 0}

Call

1
https://sendgrid.com/api/credentials/add.json?api_user=sendgrid_username&api_key=sendgrid_password&username=name&password=password&permissions={"email": 0, "web": 1, "api": 0}

Response: Success

1
2
3
{
  "message": "success"
}

Response: Error

1
2
3
{
  "error": "error reason"
}

Call

1
https://sendgrid.com/api/credentials/add.xml?api_user=sendgrid_username&api_key=sendgrid_password&username=name&password=password&permissions={"email": 0, "web": 1, "api": 0}

Response: Success

1
2
3
4
5
<?xml version="1.0" encoding="ISO-8859-1"?>

<result>
   <count>4</count>
</result>

Response: Error

1
2
3
4
5
<?xml version="1.0" encoding="ISO-8859-1"?>

<result>
   <message>error: reason</message>
</result>
Info Excluding a permission is the same as granting access rights. In other words, if you do not specify email, web or api at all, the new credentials will have access to all three. If you do not want the credentials to have access to email, web, or api, you must explicitly set those parameter options to zeroes.

Edit

Parameters

Parameter Required Requirements Description
api_user Yes alphanumeric The primary account holder’s user ID creating the new account
api_key Yes alphanumeric The primary account holder’s password
username Yes alphanumeric The existing credentials to edit
password No alphanumeric Optionally update the password
permissions No JSON array of bits

Credentials are specified using a JSON object. There are three key names: email for access to SMTP, api for programmatic access, and web for administration. The values for each are a bit, 0 for off or 1 for on.

The following example allows the specified username/password to log into the dashboard, but not send email or have access to any of the APIs:

{"email": 0, "web": 1, "api": 0}

If you do not specify any additional parameters (i.e., email, web, api), then no permissions will be changed. This behavior allows you to change passwords without having to lookup the current applied permissions.

Call

1
https://sendgrid.com/api/credentials/edit.json?api_user=sendgrid_username&api_key=sendgrid_password&username=name&password=password&permissions={"email": 0, "web": 1, "api": 0}

Response: Success

1
2
3
{
  "message": "success"
}

Response: Error

1
2
3
{
  "error": "error reason"
}

Call

1
https://sendgrid.com/api/credentials/edit.xml?api_user=sendgrid_username&api_key=sendgrid_password&username=name&password=password&permissions={"email": 0, "web": 1, "api": 0}

Response: Success

1
2
3
4
5
<?xml version="1.0" encoding="ISO-8859-1"?>

<result>
   <count>4</count>
</result>

Response: Error

1
2
3
4
5
<?xml version="1.0" encoding="ISO-8859-1"?>

<result>
   <message>error: reason</message>
</result>

Delete

Parameters

Parameter Required Requirements Description
api_user Yes alphanumeric The primary account holder’s user ID creating the new account
api_key Yes alphanumeric The primary account holder’s password
username Yes alphanumeric The credential to remove

Call

1
https://sendgrid.com/api/credentials/remove.json?api_user=sendgrid_username&api_key=sendgrid_password&username=example_user

Response: Success

1
2
3
{
  "message": "success"
}

Response: Error

1
2
3
{
  "error": "error reason"
}

Call

1
https://sendgrid.com/api/credentials/remove.xml?api_user=sendgrid_username&api_key=sendgrid_password&username=example_user

Response: Success

1
2
3
4
5
<?xml version="1.0" encoding="ISO-8859-1"?>

<result>
   <count>4</count>
</result>

Response: Error

1
2
3
4
5
<?xml version="1.0" encoding="ISO-8859-1"?>

<result>
   <message>error: reason</message>
</result>