ROOKDocs
POST

Simulate a merchant return

ENDPOINT/v1/simulate/return

Injects a merchant return (refund) in sandbox. With transaction_id of a SETTLED Transaction, appends a RETURN event; status stays SETTLED and amounts.settled nets down. With card_id or pan instead, creates a new Transaction whose first event is RETURN. Platform events: transaction.updated (or transaction.created for a standalone return) and balance.updated. Served only on the sandbox host.

Authentication & Headers

HeaderTypeRequirementDescription
AuthorizationstringREQUIREDAPI key passed as an HTTP Bearer token: Bearer rk_live_...
X-Program-IDUUIDPROGRAM-SCOPEDProgram boundary UUID that scopes the issuing card, wallet, or transfer.
Content-TypestringREQUIREDMust be application/json.
Idempotency-KeystringOPTIONALUnique UUID to prevent duplicate execution of financial creations or mutations.

Request Body Schema

application/json
transaction_idstringuuid
optional

Settled Transaction to refund. Mutually exclusive with `card_id` and `pan`.

card_idstringuuid
optional

Card for a standalone return. Mutually exclusive with `transaction_id` and `pan`.

panstring
optional

Full primary account number for a standalone return. Mutually exclusive with `transaction_id` and `card_id`. Write-only.

amountobject
REQUIRED

Refund amount. `amount` is a non-negative integer of minor units.

Properties of amount
amountanyrequired
currencystringrequired
ISO 4217 alphabetic currency code.
merchant_descriptorstringnull
optional

Merchant descriptor on a standalone return. Null when appending to an existing Transaction (the original descriptor is kept).

Response Codes & Schemas

200The Transaction after the return posted.
application/json
{
  "id": "2b5f7a28-9c4d-4e01-a6f3-1d8e0b7c2354",
  "object": "transaction",
  "type": "CARD",
  "wallet_id": "4d8f2a10-6c3e-4b91-9e5a-2f7c8d1e0b44",
  "card_id": "0c4e8f16-2a7b-4d93-b5e1-8f3a6c9d0142",
  "financial_account_id": "9b3e1c70-4d2a-4f86-8c1b-5e7a2d9f0c14",
  "status": "SETTLED",
  "transfer_ids": [
    "6f2d8a41-3c7e-4b95-a1d0-8e5c2f7b9a63"
  ],
  "result": "APPROVED",
  "decline_reason": null,
  "amounts": {
    "authorization": {
      "amount": 4280,
      "currency": "USD"
    },
    "settled": {
      "amount": 0,
      "currency": "USD"
    },
    "cardholder": {
      "amount": 0,
      "currency": "USD"
    },
    "cardholder_conversion_rate": "1.000000",
    "merchant": {
      "amount": 4280,
      "currency": "USD"
    }
  },
  "merchant": {
    "descriptor": "BLUE BOTTLE COFFEE",
    "mcc": "5812",
    "city": "Austin",
    "state": "TX",
    "country": "US",
    "acceptor_id": "333301802529120"
  },
  "network": "VISA",
  "network_risk_score": 120,
  "pos": {
    "entry_mode": "CHIP",
    "terminal": {
      "type": "POS",
      "attended": true
    }
  },
  "avs": {
    "result": "MATCH",
    "address": "MATCH",
    "postal_code": "MATCH"
  },
  "digital_wallet_type": null,
  "events": [
    {
      "id": "1a7c3e50-8b2d-4f19-a4c6-5e9f0d1b2843",
      "type": "AUTHORIZATION",
      "amount": {
        "amount": 4280,
        "currency": "USD"
      },
      "result": "APPROVED",
      "decline_reason": null,
      "rule_results": [
        {
          "rule_id": "8e4c1a92-2f70-4c45-9b3d-0a1e6f7c8290",
          "name": "Block high-risk MCC",
          "result": "ALLOW"
        }
      ],
      "created_at": "2026-08-27T14:22:00Z"
    },
    {
      "id": "3c9e5f72-0d4f-4a2b-b6e8-7f1a2c3d4055",
      "type": "CLEARING",
      "amount": {
        "amount": 4280,
        "currency": "USD"
      },
      "result": "APPROVED",
      "decline_reason": null,
      "rule_results": [],
      "created_at": "2026-08-27T14:22:10Z"
    },
    {
      "id": "7f3b5c04-2e61-4c26-90d1-0a3b4c5d6178",
      "type": "RETURN",
      "amount": {
        "amount": 4280,
        "currency": "USD"
      },
      "result": "APPROVED",
      "decline_reason": null,
      "rule_results": [],
      "created_at": "2026-08-27T16:40:00Z"
    }
  ],
  "created_at": "2026-08-27T14:22:00Z",
  "updated_at": "2026-08-27T16:40:00Z"
}
400Bad Request: malformed JSON, failed schema validation, or conflicting parameters.
application/json
{
  "error": {
    "type": "invalid_request_error",
    "code": "invalid_request",
    "message": "invalid order by: foo. Valid options are: [created_at updated_at]",
    "param": "order_by",
    "request_id": "550e8400-e29b-41d4-a716-446655440000",
    "doc_url": "https://docs.rookpayments.com/errors/invalid_request"
  }
}
401Unauthorized: missing, malformed, or unknown API key.
application/json
{
  "error": {
    "type": "authentication_error",
    "code": "authentication_error",
    "message": "A valid API key is required.",
    "param": null,
    "request_id": "550e8400-e29b-41d4-a716-446655440000",
    "doc_url": "https://docs.rookpayments.com/errors/authentication_error"
  }
}
403Forbidden: the API key is denied by RBAC, or it cannot access this program. A resource that exists on another program or organization returns `404 not_found`, not `403`.
application/json
{
  "error": {
    "type": "permission_error",
    "code": "permission_denied",
    "message": "The API key cannot access this program.",
    "param": "X-Program-ID",
    "request_id": "550e8400-e29b-41d4-a716-446655440000",
    "doc_url": "https://docs.rookpayments.com/errors/permission_denied"
  }
}
404Not Found: unknown id, or the resource is not visible to this API key.
application/json
{
  "error": {
    "type": "not_found_error",
    "code": "not_found",
    "message": "No card found for the given id.",
    "param": "card_id",
    "request_id": "550e8400-e29b-41d4-a716-446655440000",
    "doc_url": "https://docs.rookpayments.com/errors/not_found"
  }
}
409Conflict: incompatible state, or Idempotency-Key reused with a different body.
application/json
{
  "error": {
    "type": "conflict_error",
    "code": "conflict",
    "message": "The card cannot be reissued from its current state.",
    "param": null,
    "request_id": "550e8400-e29b-41d4-a716-446655440000",
    "doc_url": "https://docs.rookpayments.com/errors/conflict"
  }
}
422Unprocessable Entity: the document is valid JSON but violates a business rule.
application/json
{
  "error": {
    "type": "invalid_request_error",
    "code": "insufficient_funds",
    "message": "The source financial account does not have enough available balance.",
    "param": "amount",
    "request_id": "550e8400-e29b-41d4-a716-446655440000",
    "doc_url": "https://docs.rookpayments.com/errors/insufficient_funds"
  }
}
429Too Many Requests: the API key exceeded its rate limit.
application/json
{
  "error": {
    "type": "rate_limit_error",
    "code": "rate_limited",
    "message": "Rate limit exceeded. Retry after the number of seconds in Retry-After.",
    "param": null,
    "request_id": "550e8400-e29b-41d4-a716-446655440000",
    "doc_url": "https://docs.rookpayments.com/errors/rate_limited"
  }
}
500Internal Server Error: unexpected failure. Retry with the same Idempotency-Key.
application/json
{
  "error": {
    "type": "api_error",
    "code": "internal_error",
    "message": "An unexpected error occurred. Retry with the same Idempotency-Key.",
    "param": null,
    "request_id": "550e8400-e29b-41d4-a716-446655440000",
    "doc_url": "https://docs.rookpayments.com/errors/internal_error"
  }
}