Skip to content

Latest commit

 

History

History
110 lines (91 loc) · 2.67 KB

File metadata and controls

110 lines (91 loc) · 2.67 KB
layout page
weight 850
title Using the Web API
navigation
show
true

{% anchor h2 %} URL Format {% endanchor %}

The following is the syntax for making Web API requests:

Example WEB API URL

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.

{% codeblock lang:html %} https://api.sendgrid.com/api/blocks.get.json {% endcodeblock %}


{% anchor h2 %} Responses {% endanchor %}

{% anchor h3 %} HTTP Return codes {% endanchor %}

  • 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.

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

{% anchor h3 %} Errors {% endanchor %}

  • XML {% codeblock lang:xml %} error ... ... error messages ... ...

    {% endcodeblock %}

  • JSON {% codeblock lang:json %}{ "message": "error", "errors": [ "...error messages..." ] } {% endcodeblock %}

{% anchor h3 %} Success {% endanchor %}

  • XML {% codeblock lang:xml %} success

    {% endcodeblock %}

  • JSON {% codeblock lang:json %}{ "message": "success" } {% endcodeblock %}

{% anchor h2 %} Authentication {% endanchor %}

Each API call requires authentication. You must send the following HTTP parameters on your API calls. Your credentials will be the same as what you 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.

Example API URL with user & pass parameters

{% codeblock lang:html %} https://api.sendgrid.com/api/blocks.get.json?api_user=your_sendgrid_username&api_key=your_sendgrid_password {% endcodeblock %}

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