Clause exposes Smart Clauses® in contracts as RESTful services, that accept and produce JSON formatted data.

Each Smart Clause in a Smart Legal Contract acts as a function, accepting data and returning values. To invoke a Smart Clause you call a RESTful service, automatically exposed for each Smart Clause in a contract.

The URL to use to invoke a Smart Clause is displayed under Triggers in the smart clause properties. 

You must set the Authorization: Bearer HTTP header to invoke your smart clause, setting the value to the Bearer token for the smart clause.

You can view the supported JSON input payloads for each smart clause by navigating to the Accord Project template library via the template details.

Here is a sample cURL command for a perishable goods smart clause.

Replace the SMART_CLAUSE_ID and BEARER in the command below with the information for your smart clause.

curl --request POST \
  --url https://api.clause.io/clauses/<SMART_CLAUSE_ID>/trigger \
  --header 'authorization: Bearer <BEARER>' \
  --header 'content-type: application/json' \
  --data '{
    "$class":"org.accordproject.perishablegoods.ShipmentReceived",
    "unitCount":3200,
    "shipment":{
        "$class":"org.accordproject.perishablegoods.Shipment",
        "shipmentId":"SHIP_001",
        "sensorReadings":[
            {
                "$class":"org.accordproject.perishablegoods.SensorReading",
                "centigrade":2,
                "humidity":80,
                "shipment":"resource:org.accordproject.perishablegoods.Shipment#SHIP_001",
                "transactionId":"a"
            },
            {
                "$class":"org.accordproject.perishablegoods.SensorReading",
                "centigrade":5,
                "humidity":90,
                "shipment":"resource:org.accordproject.perishablegoods.Shipment#SHIP_001",
                "transactionId":"b"
            },
            {
                "$class":"org.accordproject.perishablegoods.SensorReading",
                "centigrade":2,
                "humidity":75,
                "shipment":"resource:org.accordproject.perishablegoods.Shipment#SHIP_001",
                "transactionId":"c"
            }
        ]
    },
    "transactionId":"99c64b8a-b3b0-408a-8ec4-7820776cd447",
    "timestamp":"2018-02-18T11:11:41.264Z"
}'
Note that for testing purposes you can trigger your smart clauses before the contract has been signed. The JSON response will be returned with the test=true attribute set, however any emitted events (such as payment obligations) will not be processed. Only contracts in the RUNNING state have their emitted events processed.

See the API documentation for more information.