Learn how to make your first API requests using the Gist API
If you're new to the Gist API, you've come to the right place.
This guide will give you everything you need to start using the Gist API to manage contacts, segments, conversations, and more. We’ll walk through accessing your API key, installing the ruby client library, and making your first API call — a simple request to the Teammates endpoint.
If you don't have a Gist account already, you’ll need to create one in order to use the API.
The simplest way to authenticate a request to the Gist API is using an API key.
Here’s how you can access it:
Note: It’s important to remember that your Gist API key provides full workspace access, so you should keep it secure, as you would with a password. Because of the potential security risks associated with exposing account API keys, Gist does not support client-side calls to the Gist API using CORS requests, nor should API keys be used in mobile apps.
If you’re creating integrations that require access to Gist on behalf of other Gist users, you’ll want to set up authentication via Oauth instead.
You can make calls to the Gist API with whichever method you usually use to make HTTP requests, but Gist offers client libraries that make interacting with the API even simpler.
To install the client library Ruby language:
gem 'gist-api-ruby'
To test that you have everything set up correctly, we’ll make a simple request to the /teammates
endpoint. Hitting this endpoint will return a list of teammates in your workspace.
CURL
curl --request GET \
--url https://api.getgist.com/teammates \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
Ruby Client
require 'gist-api-ruby'
# With an OAuth or Personal Access token:
gist = Gist::Client.new(access_token: 'Bearer <token>')
api_response = gist.teammates.find_all
puts api_response
If everything was set up correctly and the request to endpoint was a success, the response should look like the following:
[
{
"id": 2,
"name": "John Doe",
"email": "[email protected]",
"avatar": "https://avatar.tobi.sh/[email protected]?size=120&type=svg&text=JD",
"agent_status": "offline",
"last_active_on": "2022-03-11T11:00:08.502Z",
"away_mode_enabled": false,
"team_ids": [
2,
52,
226,
],
"has_inbox_seat": true
}
]
Now that you’re successfully making authenticated requests to the API with your API key and client library of choice, you’re ready to dive into the Gist API.
The first thing you may want to do is learn how to add new contacts to your workspace using the API. You may also want to familiarize yourself with the Gist API docs, which outline some of the common conventions you’ll run into across the API.