Reload a saved contract

Get a saved contract's payload back, with fresh pricing, so the contract form can be refilled. The console uses this call when a draft, a duplicate or an amendment is opened.

GEThttps://api.spyne.ai/credit/v6/contracting/prefill-contract-data
AuthBearer token (console user)Rate limitNot documentedProcessingSynchronous; waits for the contract read and the pricing and rooftop name refresh.

The contract is looked up by ID and returned as it was last saved. Before returning, the call:

  • sets contractSource to dealhub or console,
  • replaces pricing with the current catalog in the contract's currency (for Reseller contracts, resellerPricing instead),
  • maps old Studio AI plan names to Pro or Lite,
  • refreshes rooftops[].rooftopName from the live rooftop name when the rooftop already has a teamId,
  • fills line_items and line_items_latest.

For contracts already in Contracted or Contract-Live, it can also correct billingDetails.billingEntity from the dealer group's billing customer record. Nothing is written. If a refresh step fails, the stored value is returned.

Send the bearer token of a signed-in Spyne Console user in Authorization: Bearer YOUR_TOKEN. The token is checked against the user validation endpoint on every call.

Before you call it

  • You need a contractId. It comes from data.contractId of an earlier Save or submit a contract call, or from the contract history list.
  • The call is synchronous. It waits for the contract read and the pricing and rooftop name refresh. The rate limit is not documented.

Request

Requiredalways send
Request checklist
  1. Authenticate: send the Authorization: Bearer YOUR_TOKEN header.
  2. Name the contract: pass contractId as a query parameter.

Headers

ParameterTypeRequiredDescription
AuthorizationstringRequiredBearer YOUR_TOKEN

Query parameters

ParameterTypeRequiredDescription
contractIdstringRequiredID of the contract to load.

Sample request

curl -X GET "https://api.spyne.ai/credit/v6/contracting/prefill-contract-data?contractId=CONTRACT_ID" \
  -H "Authorization: Bearer YOUR_TOKEN"
import requests

res = requests.get(
    "https://api.spyne.ai/credit/v6/contracting/prefill-contract-data",
    params={"contractId": "CONTRACT_ID"},
    headers={"Authorization": "Bearer YOUR_TOKEN"},
)
print(res.status_code, res.json())
const res = await fetch(
  "https://api.spyne.ai/credit/v6/contracting/prefill-contract-data?contractId=CONTRACT_ID",
  { headers: { Authorization: "Bearer YOUR_TOKEN" } }
);
console.log(res.status, await res.json());

Sample response

The 200 response is shortened.

{
  "message": "Contract payload fetched successfully",
  "error": false,
  "code": "",
  "details": null,
  "data": {
    "isDraft": true,
    "contractDetails": { "enterpriseId": "ENTERPRISE_ID", "currency": "USD", "dealType": "New Deal", "customerType": "Individual Dealer", "managerName": "" },
    "customerDetails": { "legalName": "Example Motors LLC", "brandName": "Example Motors" },
    "rooftops": [{ "rooftopName": "Example Motors", "bundle": "bundle-1", "productsLines": [] }],
    "signatoryDetails": { "name": "Jane Doe", "email": "[email protected]" },
    "billingDetails": { "billingFrequency": 12 },
    "terms": { "contractTerm": 12 },
    "summary": { "totalOneTimeFee": 0, "totalMonthlyRecurringFee": 0, "totalAnnuallyRecurringFee": 0 },
    "pricing": { "conversationalAi": { "type": "<type>", "allowedProducts": {}, "items": {} } },
    "contractSource": "console",
    "line_items": { "type": "bundle", "value": { "bundle-1": {} } },
    "line_items_latest": { "type": "bundle", "value": { "bundle-1": {} } }
  }
}
{ "message": "Invalid Token", "error": true, "code": "ERROR_AUTH_401", "details": null, "data": null }
{
  "message": "Contract not found for the given contract ID",
  "error": true,
  "code": "ERROR_NOT_FOUND_404",
  "details": null,
  "data": null
}
{
  "message": "<error message>",
  "error": true,
  "code": "ERROR_SERVER_500",
  "details": null,
  "data": null
}

Response parameters

ParameterTypeDescription
dataobjectThe contract payload as it was last saved (the same shape as the body of Save or submit a contract), plus the fields below.
data.contractSourcestringdealhub if the contract came from a DealHub quote, otherwise console.
data.pricingobjectCurrent pricing catalog in the contract currency (non-Reseller contracts).
data.resellerPricingobjectCurrent reseller pricing catalog (Reseller contracts only).
data.line_itemsobject or nullStored line items, or line items computed from the contract tree when none are stored.
data.line_items_latestobject or nullSame value as line_items.

Errors

StatusReasonWhen it happens
400Missing inputcontractId is not sent. The framework rejects the request before the handler runs. The body is not documented in code.
401Invalid or missing tokenNo Bearer token, or the token failed validation.
404Contract not foundNo contract has this ID.
408Request timed outThe token validation call could not connect.
500Server errorAny other error, including a contractId that is not a valid ID format. The message is the underlying error text.

What happens next

Refill the form with data, let the user edit, then call Save or submit a contract with the same contractId while the contract is still a draft.

Called before: Get contract config. Called after: Save or submit a contract.


Did this page help you?