See api-docs Menu

Create Environment Variable

Early Preview

This API is in early preview and may be subject to change. Please contact your account manager if you are interested in trying Smart Hooks.

Use this API to create a new Hook Environment Variable and define its value.

Environment Variables are a safe and convenient way to inject secrets or common configuration items into hook functions.

For example, you may want to call an external API from within a hook function so could therefore define an API_KEY environment variable and include it in your hook function definition.

For more detail on how to use environment variables within a hook function see the Smart Hooks Overview.

Resource URL

https://<api-domain>/api/2/hooks/envs

Header Parameters

Authorization

required

string

Set to bearer <access_token>.

Set <access_token> to the access token you generated using the Generate Token API.

The access token must have been generated using an API credential pair created using the scope required to call this API. This API can be called using any one of the following scopes: Manage All.

In order to use Smart Hooks your API Credentials must be created after 21st October 2020.

Content-Type

required

string

Set to application/json.

Request Parameters

name

required

string

The name for the environment variable that will be used to retrieve the value from a hook function.

value

required

string

The secret value that will be encrypted at rest and injected in applicable hook functions at run time.

Sample Request

{
    "name": "SAMPLE_VAR",
    "value": "helloworld"
}

Sample Responses

{
    "id": "80f65e4b-4325-4ee6-86af-9e6b8793f125",
    "name": "SAMPLE_VAR",
    "created_at": "2020-10-22T22:07:48.236Z",
    "updated_at": "2020-10-22T22:07:48.236Z"
}

Typically, this error means that your Authorization header value is missing or incorrectly formatted. The Authorization header value should use this format: bearer:<access_token>.

{
    "name": "UnauthorizedError",
    "message": "The request requires user authentication."
}

Indicates that the syntax of the request is good but a value supplied is not valid.

{
    "message": "Validation failed: The associated Policy with ID 0 could not be found",
    "name": "UnprocessableEntityError"
}

Postman Collection

Replace sample variables indicated by {{ }} with your actual values.

Download for the Smart Hooks API

Sample Code

cURL

Replace sample values indicated by < > with your actual values.

Create Hook Environment Variable

curl 'https://<api-domain>/api/2/hooks/env_vars' \
-X POST \
-H "Authorization: bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
    "name": "SAMPLE_VAR",
    "value": "helloworld"
}'

Have a Question?

Have a how-to question? Seeing a weird error? Ask us about it on StackOverflow.

Found a bug? Submit a support ticket.

Have a product idea or request? Share it with us in our Ideas Portal.