Get template types

In this tutorial, you will learn how to list template types available in your Oneflow account.

About template types

Template types is one of the central concepts in Oneflow when building integrations. In template types, you create and define your data fields.

Template types connect contracts to the correct webhooks and allow users in the Oneflow application to set which integration the template should belong to and the contracts created from it.

Step 1. Enable the template types extension

To be able to use template types, you have to enable the Template types extension.

To do that, go to the Oneflow application Account module > Extensions page, and toggle the Template types extension:

🚧

Note:

Currently, the extension is called Template groups and will be renamed to Template types shortly.

Please see Building a partner system integration](building-a-partner-integration) for more information about using template types in partner system integrations.

Step 2. Obtain necessary information

To run the script described in this tutorial, you’ll need the following data:

Headers
x-oneflow-api-token You will only be able to run the script by using a valid API token. You can create an API token in the Oneflow web application. Find out more in the Authentication section.
Query parameters
offset Offset for pagination.
limit Limit for pagination.

Step 3. Run the code

Replace the values of the parameters in the following command with the actual data from your account and run it:

curl --request GET \
  --url https://api.oneflow.com/v1/template_types?offset=XX&limit=YY \
  --header 'Accept: application/json' \
  --header 'x-oneflow-api-token: API_TOKEN'
import requests

headers = {
    'Accept': 'application/json',
    'x-oneflow-api-token': API_TOKEN
    }

response = requests.get('https://api.oneflow.com/v1/template_types?offset=XX&limit=YY', 
                        headers=headers)

print(response.json())

Expected response

This request returns the requested template types list in JSON format.

{
  "_links": {
    "next": {
      "href": "https://api.oneflow.com/v1/template_types?offset=1&limit=1"
    },
    "previous": {
      "href": null
    },
    "self": {
      "href": "https://api.oneflow.com/v1/template_types?offset=0&limit=1"
    }
  },
  "count": 2,
  "data": [
    {
      "_links": {
        "self": {
          "href": "https://api.oneflow.com/v1/template_types/1"
        }
      },
      "created_time": "2020-10-27T16:45:56+00:00",
      "description": "simple template type",
      "extension_type": "hubspot",
      "id": 1,
      "name": "test_template_types",
      "updated_time": "2020-10-27T16:45:56+00:00"
    },
    {
      "_links": {
        "self": {
          "href": "https://api.oneflow.com/v1/template_types/2"
        }
      },
      "created_time": "2021-07-28T15:45:00+00:00",
      "description": "sample template type",
      "extension_type": "adocka",
      "id": 2,
      "name": "sample_adocka_template_types",
      "updated_time": "2021-07-28T15:45:00+00:00"
    }
  ]
}

Please see the Template type section for more information about the output.

Response codes

StatusMeaningDescription
200OKReturns the list of template types.
400Bad RequestInvalid format or content of the request.
401UnauthorizedThe API token or the user email is invalid.
403ForbiddenThe request is not authorized by the server.

Did this page help you?