Each of your contract clauses has a REST API that you can use to trigger your clause. This API and the access token are generated automatically for you and are available from the connections tab of the contract editor.

To trigger your Smart Clause® you should send in a JSON object that corresponds to request object from your Cicero template. Accord Project templates are documented in the Accord Project Template Library. All possible Trigger payloads associated with a template are documented under the Request Types heading.

Using the docs as a guideline, you can send a conforming payload to the Clause REST API to test your integration.

The Clause execution REST API also requires you to send an HTTP POST message and to set the Content-Type header to application/json.

A sample client application is available on GitHub.

A sample curl command for the Fragile Goods sample (for Linux or MacOS only) to trigger your Smart Clause from the terminal.

curl -X POST \
  https://api.clause.io/clauses/CLAUSE_ID/trigger \
  -H 'Authorization: Bearer TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "$class": "io.clause.demo.fragileGoods.DeliveryUpdate",
    "startTime": "2018-09-13T13:10:17.059Z",
    "finishTime": "2018-09-13T13:10:17.059Z",
    "status": "ARRIVED",
    "accelerometerReadings": [
        17.58
    ]
}'

Optionally, you can also configure Clause to perform an action automatically when your clause executes.

You can form more complex integrations by orchestrating a call to the Clause API with other services. For example, by using Node-RED.

Note that requests to the same Smart Clause are not queued. That is that two requests sent in quick succession may be processed in parallel. To ensure that you have predictable outputs, you should queue responses in the client application. For example, by waiting for a response to a request before sending another one.

Troubleshooting

If you have trouble sending a message to the REST API, ensure that your JSON object is well formed, and that it is accepted by your contract. You can confirm this locally on your machine with the Cicero CLI tool (i.e. run cicero execute from your template folder)

If your request is valid you will receive a JSON object back that is an instance of the response CTO model for your Cicero Template.