Change log

Getting Started With the API

Treepl CMS uses APIs for just about all of its CMS functionality (adding, editing, finding and deleting content) and these APIs are progressively being opened up for public access for use with connecting external systems to your Treepl CMS instances.

Treepl CMS’s API is built using the REST architecture supporting requests over HTTPS authenticated via OAuth 2.0 with responses provided in JSON format.

Treepl CMS uses API keys to authenticate API requests and all API requests must be made over a secure HTTPS connection. Connection attempts over HTTP will not be accepted.

Be sure to keep your API keys secure. Do not share your secret API keys in publicly accessible areas such as GitHub and client-side code as these keys can provide access to your website instance.

Add an API Application (Generate API Keys)

In your Treepl CMS admin, for the website you wish to connect to, you will first need to register an API application as a means to generate your API keys.

Under ‘Settings’ > ‘API Applications’, click the “Create New” button at the top to register a new application, or click the pencil icon () next to an existing application to view those keys.

You can also delete an API Application via the trash can icon () next to the relevant application. Deleting an application will disable those API keys in any location they are currently being used.

Revoking API access for a specific application can be done either by deleting the API Application from the website admin or, when editing the API Application, disabling it or refreshing the ‘Client Secret’.

With an API Application created, you can click on the ‘Client ID’ and ‘Client Secret’ to copy those values to your clipboard and use them in your API project or 3rd party service.

API Authentication

All Treepl CMS API endpoints require an Authorization header with the token retrieved by Retrieve Access Token Endpoint.

Retrieve Access Token Endpoint

  • URL
    • /api/v1/oauth/token
  • Type
    • POST
  • Content-Type
    • application/x-www-form-urlencoded
  • POST params
    • grant_type
      • client_credentials
    • client_id
      • [client_id]
    • client_secret
      • [client_secret]
    • scope
      • public_api

Access Token Responses

On Success return bearer token (life time 4 hours):

{
    "access_token": "tokenStringHere",
    "expires_in": 14400, 
    "scope": "public_api", 
    "token_type": "Bearer" 
}

If an app is disabled, show error:

{
    "ErrorCode" : 401001,
    "Message"   : "The application is disabled"
}

If clientId/clientSecret pair wasn't found, show error:

{
    "ErrorCode" : 401002,
    "Message"   : "Invalid client_id and/or client_secret"
}

If site plan is less than Pro, show error:

{
    "ErrorCode" : 401003,
    "Message"   : "Public API is restricted for your site plan"
}

If scope is invalid, show error:

{
    "ErrorCode" : 401006,
    "Message"   : "Invalid Scope"
}

If grand_type is invalid, show error:

{
    "ErrorCode" : 401007,
    "Message"   : "Invalid Grant Type"
}

API Endpoint Token Errors

If any request doesn't contain access token or token can't be found in DB, show error:

{
    "ErrorCode" : 401000,
    "Message"   : "Invalid Access Token"
}

ElseIf any request contains access token but it has been expired, show error:

{
    "ErrorCode" : 401004,
    "Message"   : "Access Token expired"
}

ElseIf an app asociated with the access token is disabled, show error:

{
    "ErrorCode" : 401001,
    "Message"   : "The application is disabled"
}

ElseIf access token is revoked, show error:

{
    "ErrorCode" : 401005,
    "Message"   : "The Access Token has been revoked"
}

Form Submission Data

Data should be submitted via multipart/form-data MIME type.
For Cases, Bookings and Advanced CRM Groups the names of the fields should be the same as those used for a general form submit process.

Pattern

Key
Value
[FormFieldAlias]
[value1]
[CRMGroupAlias]_[CRMGroupFieldsAlias]
[value2]

Example

Key
Value
Email
test@test.com
DateCustomGroup_DateStart
2012-12-29


External Resources

There are currently no external resources available.

Please let us know if you have any other contributions or know of any helpful resources you'd like to see added here.


Questions?

We are always happy to help with any questions you may have.
Visit the Treepl Forum for community support and to search previously asked questions or send us a message at support@treepl.co and we will consult you as soon as possible.