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:

MethodAction
GETRetrieve a resource
POSTCreate a new resource
PATCHPartially modify an existing resource
DELETERemove a resource

Headers

There are several headers you may need to include in your request.

HeaderUse Case
apiKeyThe apiKey header authorizes your request and includes your unique API key — learn more about authentication.
AcceptThe Accept header tells the API in which format to return the response. By default, this is set to application/json.
Content-TypeThe 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:create scope.

🚧

You can use the "Try It!" feature in the reference documentation to make requests to the API. However, be aware that using this function makes a an actual to the API—and therefore, will get and/or post real data to/from your Teachable school.


Did this page help you?