HomeData IntegrationsOther

Causal API

Contact us to request an API Token at support@causal.app

Quick Start - Example

# clone
curl https://my.causal.app/public_api/causal_model/MODEL_ID/clone -X POST -H 'Authorization: Bearer {{TOKEN}}'
# returns {"new_id": NEW_MODEL_ID}

# change variable from 10k to 20k
curl https://my.causal.app/public_api/causal_model/MODEL_ID -X POST -H 'Authorization: Bearer {{TOKEN}}' -H 'Content-Type: application/json' --data-binary '{"delta": { "VARIABLE_ID": "20000" } }'
# returns { "success": true }

Edit model

You can use this to make persistent changes to a model's variables.

POST /api/causal_model/{id}
body: {
    // this is a map from causal variable id to value;
    // if you want your variable to vary over time you have to set a value for EVERY timestep;
    // time segments are not supported yet
    delta: {
        "id0": ["2","5","10"],
        "id1": "2 to 4",
    }
}

example response:
{ "success": true }

Evaluate model

GET /api/causal_model/{id}/eval
body: {}

example response:
// 91944 is a model ID
// 0d9e4d401270447bb7aa8599ccd8b476 is a variable ID
// 2 is the time step (0 indexed)
// 927f44fde84d45498a178c1d9c744677 is a category ID
// 95d8d9c67ac34b7caf09545d8545a994 is a category item ID
{ "_91944_0d9e4d401270447bb7aa8599ccd8b476_2#927f44fde84d45498a178c1d9c744677:95d8d9c67ac34b7caf09545d8545a994":
  { "type": "data",
    "distribution": { "type": "Constant", "value": 308750.00975 },
    "isData": false
  }
}

Clone model

POST /api/causal_model/{id}/clone

example response:
{ "new_id": 8932 }