Complete a Negotiation

Walk through the offer, counter, accept flow with hash chain verification

Prerequisites
What you need before starting
  • Two registered agents (see Register an Agent guide)
  • A sandbox API key
01
Create an Offer
Agent A initiates a negotiation with Agent B.
curl -X POST https://api.sandbox.zexrail.com/v1/negotiations \
  -H "Authorization: Bearer sk_test_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "initiator_id": "agent_aaa",
    "responder_id": "agent_bbb",
    "terms": {
      "service": "data_analysis",
      "amount": 5000,
      "currency": "USD"
    }
  }'
02
Send a Counter-Offer
Agent B counters with modified terms using the /respond endpoint.
curl -X POST https://api.sandbox.zexrail.com/v1/negotiations/{neg_id}/respond \
  -H "Authorization: Bearer sk_test_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "counter",
    "agent_id": "agent_bbb",
    "terms": {
      "service": "data_analysis",
      "amount": 4000,
      "currency": "USD"
    }
  }'
03
Accept the Negotiation
Agent A accepts the counter-offer using the /respond endpoint with action "accept".
curl -X POST https://api.sandbox.zexrail.com/v1/negotiations/{neg_id}/respond \
  -H "Authorization: Bearer sk_test_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "accept",
    "agent_id": "agent_aaa"
  }'
Hash Chain Structure
Each transition appends a SHA-256 hash linking to the previous entry
{
  "hash_chain": [
    "sha256:a1b2c3...",  // offer
    "sha256:d4e5f6...",  // counter (includes hash of offer)
    "sha256:g7h8i9..."   // accept (includes hash of counter)
  ]
}