POST
/
v1
/
code
/
apply
curl --request POST \
  --url https://instantapply.endpoint.relace.run/v1/code/apply \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "initialCode": "function calculateTotal(items) {\n  let total = 0;\n  \n  for (const item of items) {\n    total += item.price * item.quantity;\n  }\n  \n  return total;\n}",
  "editSnippet": "// ... keep existing code\n\nfunction applyDiscount(total, discountRules) {\n  let discountedTotal = total;\n  \n  if (discountRules.percentOff) {\n    discountedTotal -= (total * discountRules.percentOff / 100);\n  }\n  \n  if (discountRules.fixedAmount && discountRules.fixedAmount < discountedTotal) {\n    discountedTotal -= discountRules.fixedAmount;\n  }\n  \n  return Math.max(0, discountedTotal);\n}",
  "stream": false
}'
{
  "mergedCode": "function calculateTotal(items) {\n  let total = 0;\n  \n  for (const item of items) {\n    total += item.price * item.quantity;\n  }\n  \n  return total;\n}\n\nfunction applyDiscount(total, discountRules) {\n  let discountedTotal = total;\n\n  if (discountRules.percentOff) {\n    discountedTotal -= (total * discountRules.percentOff / 100);\n  }\n\n  if (discountRules.fixedAmount && discountRules.fixedAmount < discountedTotal) {\n    discountedTotal -= discountRules.fixedAmount;\n  }\n\n  return Math.max(0, discountedTotal);\n}",
  "usage": {
    "prompt_tokens": 174,
    "completion_tokens": 145,
    "total_tokens": 319
  }
}

Authorizations

Authorization
string
header
required

API key Authorization header using the Bearer scheme. Rate limiting applies for certain API keys.

Body

application/json

Initial code and edits to apply

The body is of type object.

Response

200
application/json

Code successfully applied

The response is of type object.