This guide will help you get up and running making your first Chariot API call in just a few minutes. You will create an access token, get a CID for a nonprofit, and query for the grants of that CID.

🚧

This guide assumes you have already been shared a client_id and client_secret. If that is not the case, please email [email protected].

1. Generate an access token 🔑

First, you'll need to create an access token that lets you access the APIs. Fill in the provided client_id and client_secret to in the preferred code snippet and get an access token.

curl --request POST \
  --url 'https://chariot-sandbox.us.auth0.com/oauth/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data 'audience=https://api.givechariot.com&grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET'
POST https://chariot-sandbox.us.auth0.com/oauth/token
Content-Type: application/x-www-form-urlencoded

audience=https://api.givechariot.com&grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET
var request = require("request");

var options = { method: 'POST',
  url: 'https://chariot-sandbox.us.auth0.com/oauth/token',
  headers: { 'content-type': 'application/x-www-form-urlencoded' },
  form:
   { client_id: 'YOUR_CLIENT_ID',
     client_secret: 'YOUR_CLIENT_SECRET',
     audience: 'https://api.givechariot.com',
     grant_type: 'client_credentials' }
   };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

2. Create a CID for a nonprofit 🪪

Now that you have an access token, you're set to initiate an API request. We're going to utilize Chariot's APIs to generate a CID (Connect Identifier) for a nonprofit organization. This CID is a crucial element needed to activate the DAFpay button.

To create a CID to a nonprofit, we first establish the nonprofit's ID by utilizing their EIN (Employer Identification Number). Following that, we proceed to create a Connect with the nonprofit's ID.

2a. Create Nonprofit :hospital:

The Create nonprofit endpoint registers a new nonprofit or confirms its existence within the Chariot system.

For registration, it's necessary to supply the nonprofit's EIN and details for a contact person at the nonprofit for Chariot's customer support purposes.

Below are a few examples of different implementations. Modify the user object, ein field, and access token from step 1 before making the request.

curl --request POST \
     --url https://sandboxapi.givechariot.com/v1/nonprofits \
     --header 'accept: application/json' \
     --header 'authorization: Bearer ACCESS_TOKEN' \
     --header 'content-type: application/json' \
     --data '
{
     "user": {
          "email": "[email protected]",
          "phone": "3051234321",
          "firstName": "Han",
          "lastName": "Solo"
     },
     "ein": "123456789"
}
'
const options = {
  method: 'POST',
  headers: {
    accept: 'application/json',
    'content-type': 'application/json',
    authorization: 'Bearer <YOUR_TOKEN_FROM_STEP_1_HERE>'
  },
  body: JSON.stringify({
    user: {
      email: '[email protected]',
      phone: '3051234321',
      firstName: 'Han',
      lastName: 'Solo'
    },
    ein: '123456789'
  })
};

fetch('https://sandboxapi.givechariot.com/v1/nonprofits', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Bravo! You have just created a nonprofit in the Chariot system. Mark down the nonprofit's id and now let's create a Connect for this nonprofit.

2b. Create Connect 🪪

The Create Connect endpoint creates a Connect record or retrieves it if a Connect already exists for this nonprofit in Chariot's system.

To create a Connect, the nonprofit's id must be provided, which you should have from the previous step!

Below are a few examples of different implementations. Modify the NONPROFIT_ID query parameter with the nonprofit's id. Don't forget to add the access_token!

curl --request POST \
     --url 'https://sandboxapi.givechariot.com/v1/connects?nonprofit=NONPROFIT_ID' \
     --header 'accept: application/json' \
     --header 'authorization: Bearer ACCESS_TOKEN' \
     --header 'content-type: application/json'
const options = {
  method: 'POST',
  headers: {
    accept: 'application/json',
    'content-type': 'application/json',
    authorization: 'Bearer YOUR_TOKEN_FROM_STEP_1_HERE'
  }
};

fetch('https://sandboxapi.givechariot.com/v1/connects?nonprofit=NONPROFIT_ID', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Amazing! You can now start Integrating Connect to build a front end and start receiving grants for this nonprofit.

3. List Grants 💵

After submitting several grants through Chariot Connect, you can access Chariot's APIs to retrieve information on those grants.

The List Grants endpoint lists all the grants for a particular CID.

To retrieve grants, you must supply the API key of the Connect. You can obtain the API Key by using the Get Connectendpoint or by noting it down from the setup process when you initially created the Connect.

Now we are ready to list grants. Below are a few examples of different implementations. Modify the API_KEY with the Connect's API key. Don't forget to add the access_token!

curl --request GET \
     --url 'https://sandboxapi.givechariot.com/v1/grants?pageLimit=10' \
     --header 'accept: application/json' \
     --header 'authorization: Bearer ACCESS_TOKEN' \
     --header 'x-chariot-api-key: API_KEY'
const options = {
  method: 'GET',
  headers: {
    accept: 'application/json',
    authorization: 'Bearer YOUR_TOKEN_FROM_STEP_1_HERE',
    'x-chariot-api-key': 'API_KEY'
  }
};

fetch('https://sandboxapi.givechariot.com/v1/grants?pageLimit=10', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));