Requests
Requests made to the API are made using the developers.teachable.com base URL.
The API uses standard HTTP methods for indicating which actions to take on a resource:
| Method | Action |
|---|---|
| GET | Retrieve a resource |
| POST | Create a new resource |
| PATCH | Partially modify an existing resource |
| DELETE | Remove a resource |
Headers
There are several headers you may need to include in your request.
| Header | Use Case |
|---|---|
| apiKey | The apiKey header authorizes your request and includes your unique API key — learn more about authentication. |
| Accept | The Accept header tells the API in which format to return the response. By default, this is set to application/json. |
| Content-Type | The Content-Type header tells the API about the format of the data being sent. This is required when including a request body with a POST or PATCH request, and must be set to application/json. |
Example header:
curl --header 'apiKey: YOURAPIKEYHERE' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json'Request bodies
When making POST or PATCH requests, you must add a request body (i.e., the included data) in JSON.
Example request body format:
cURL --data '
{
"key": value
}
'For example, if you want to use the API to create a new user in your school, you will need to make a POST request to the users endpoint. This will require you to include a request body in your call, as you'll need to include some data about the new user (e.g., their name and email address).
For this particular example, the request body of a call to the users endpoint is formatted as follows:
cURL --data '
{
"email": "[email protected]",
"password": "password123"
}
'Example of a request
As mentioned above, your request might need various header and body content, depending on the request type you're making.
For example, a call to the users endpoint requires the following:
- A request type (i.e., POST)
- A base URL where the call is made (i.e.,
developers.teachable.com) - A header with both your API key for authorization, and an indicated
Content-type - A request body that includes data about the new user
All together, a call to the users endpoint would be formatted as follows:
curl --request POST \
--url 'https://developers.teachable.com/v2/users' \
--header 'Content-Type: application/json' \
--header 'apiKey: YOURAPIKEYHERE' \
--data '
{
"email": "[email protected]",
"password": "password123",
"name": "John Doe"
}
'Requires the
users:createscope.
Updated 8 days ago