API Quickstart
Create consent arbitration cases programmatically. A case created through the API lands in the Ready to Sign state; you then sign and pay through your dashboard.
-
1
Create an API key at /settings/api-keys and copy its full value (shown only once).
-
2
Install the only dependency:
pip install requests -
3
Paste your key into the script below (replace
PASTE_YOUR_KEY_HERE) and runpython create_consent_case.py.
Authenticate every request with a bearer token:
Authorization: Bearer dvarb_your_key_here
create_consent_case.py
"""DecisionLayer API quickstart: create a consent arbitration case.
The only thing you need to change is API_KEY below. Create a key at
https://www.decisionlayer.ai/settings/api-keys
Then run:
pip install requests
python create_consent_case.py
"""
import requests
# 1. Paste your API key here (from /settings/api-keys).
API_KEY = "PASTE_YOUR_KEY_HERE"
# 2. Base URL of the DecisionLayer API. Use http://localhost:8000 locally.
BASE_URL = "https://www.decisionlayer.ai"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
def main() -> None:
# Create a small sample attachment so the demo includes a contract file.
with open("sample_contract.txt", "w") as handle:
handle.write("Sample contract for the DecisionLayer consent demo.\n")
# The fields below mirror the consent web form. Claimant details default
# to the API key owner's account when omitted.
data = {
"question_for_arbitration": "Respondent kept a $3,500 deposit.",
"financial_demand_usd": "3500.00",
"other_relief": "Return of any project files.",
"respondent_first_name": "Jordan",
"respondent_last_name": "Chen",
"respondent_email": "jordan.chen@example.com",
}
with open("sample_contract.txt", "rb") as contract:
files = {
"contract_files": ("sample_contract.txt", contract, "text/plain"),
}
response = requests.post(
f"{BASE_URL}/api/v1/cases",
headers=HEADERS,
data=data,
files=files,
timeout=60,
)
if response.status_code != 201:
print(f"Request failed ({response.status_code}):")
print(response.json())
raise SystemExit(1)
result = response.json()
case = result["case"]
print(f"Created consent case: {case['id']}")
print(f"Status: {case['status']}")
print(f"Sign it here: {result['sign_url']}")
# List your cases to confirm it shows up.
listing = requests.get(f"{BASE_URL}/api/v1/cases", headers=HEADERS, timeout=60)
listing.raise_for_status()
print(f"You now have {len(listing.json())} consent case(s).")
if __name__ == "__main__":
main()
Understanding errors
Every error returns a consistent JSON shape with a list of
actionable details:
{
"error": {
"status": 422,
"message": "Your request could not be processed.",
"details": [
"Field 'respondent_email' is required. Provide the respondent's email address, e.g. respondent_email='jordan@example.com'."
]
}
}