Find us at our new Help Center where we've combined our documentation and knowledgebase articles in one easy-to-search location.
We aren't updating the Developer Portal anymore, except for the Element Docs — all updates happen in the Help Center. We're retiring the Developer Portal as you know it in:
You can expose formulas that have manual triggers as a resource, known as Formula as a Resource or FaaR. This enables you to use the formula as a synchronous API request. After you update a formula to be used as a resource, you can make API requests to it at https://api.cloud-elements.com/elements/api-v2/<resourceName>
. Using a formula as a resource enables you to further remove logic from your applications and also provides the ability to more efficiently chain requests together.
The API requests are synchronous and so a response is required for further processing. To maintain efficiency, Cloud Elements imposes a processing time limit. If the request reaches that limit, the response notifies you.
To use a formula as resource:
/formula1
.To test the formula as a resource, you can make the request yourself or use our API docs. Either way, you must provide a Formula Instance ID
. You can find the ID on a Formula Instance Card under the title.
To access the docs for the formula:
To make an API request to the formula as a resource, include the formula instance (elements-formula-instance-id
) in the header in addition to the usual User and Organization. For example:
curl -X GET \
https://api.cloud-elements.com/elements/api-v2/formula1 \
-H 'authorization: User <USER_SECRET>, Organization <ORGANIZATION_SECRET>' \
-H 'elements-formula-instance-id: 28683' \
When you create a Formula as a Resource you can specify status codes and descriptions. To include a status code and result in the response to a FaaR request:
Include a script like the following in the step:
done({
statusCode: xxx
result: {
label: 'message'
}
})
Save the step.
Property | Description |
---|---|
statusCode | The status code that you want to return in the response, such as 200 , 401 , or 502 . The value must be a valid status code. |
result | The body of the response which can be anything related to the status code such as an array of objects, a single object, or text. The example above includes an array containing a key value pair with a label and a message. |
You can pass parameters into formulas as a resource, and then access the results of the response within the context of the formula.
To include a parameter in a formula as a resource:
When you make the request, pass the parameter. An example cURL request with a query parameter to the resource called formula1
, your endpoint would be:
curl -X GET \
https://api.cloud-elements.com/elements/api-v2/formula1?<queryParameter> \
-H 'authorization: User <USER_SECRET>, Organization <ORGANIZATION_SECRET>' \
-H 'elements-formula-instance-id: 28683' \
Access data returned in the response to the request by using a script step. The data is available through trigger.args.request.query
. An example script that passes query data containing an email address to the console would be:
var queryObject = trigger.args.request.query;
function getThatEmailAddress(emailAddressObject){
console.log(emailAddressObject['email']);
}
done(getThatEmailAddress(queryObject))