SendGrid offers a Web API that allows customers to retrieve information about their account such as statistics, bounces, spam reports, unsubscribes, and other information. This API is not RESTful since for most calls both GET and POST HTTP verbs can be used interchangeably, and other verbs are not supported.


URL Format

The following is the syntax for making Web API requests:

https://api.sendgrid.com/api/[module].[action].[format]
  • [module] - The API endpoint to call, e.g. blocks.
  • [action] - Each module supports multiple actions such as add, get, and delete.
  • [format] - This determines the response format. It can be either json for a JSON response or xml for an XML response.

HTTP Return codes

  • 2XX - The API call was successful.
  • 4XX - The API call had an error in the parameters. The error will be encoded in the body of the response.
  • 5XX - The API call was unsuccessful. You should retry later.

Responses

The formats supported are XML and JSON. Errors and success responses are described below while calls that provide information have their own return structure.

Errors

  • XML
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <result>
       <message>error</message>
       <errors>
          ...
          <error>... error messages ...</error>
          ...
       </errors>
    </result>
    
  • JSON
    1
    2
    3
    4
    5
    6
    
    {
      "message": "error",
      "errors": [
        "...error messages..."
      ]
    }
    

Success


Authentication

Each API call requires authentication. You must send the following HTTP parameters on your API calls. Your credentials are the same used for your SMTP authentication and/or website.

  • api_user - This is the same credential used for your SMTP settings, and for logging into the website.
  • api_key - This is the same password to authenticate over SMTP, and for logging into the website.

For detailed information on the available Web API methods, select one from the tree on the left.