| Status | Draft. |
| Version | 0.1.0, 2026-11-28 |
| Profile of | None: an OCI protocol |
| Depends on | OCI-0 Core, OCI-1 Trust Registry, OCI-PAY-1 Payment Addressing, OCI-PAY-2 Payments Switch, OCI-PAY-3 Payment Apps |
| Used by | (none yet) |
| Reference implementation | ocipay-api (both switches run it) |
1. Purpose
Each country in OCI-Pay has one payments switch, run by its national payments corporation (NPC). Banks call only their own country’s switch. A payment app calls only its home switch (OCI-PAY-3). OCI-PAY-4 says how two countries’ switches talk to each other over the link.
Six kinds of traffic cross the link:
- Looking up who an address belongs to, when the account is in the other country.
- Pricing a cross-border payment (a quote).
- The cross-border payment itself.
- A request for money (a collect request) from a payee in one country to a payer in the other, and every change to its status.
- A payment app’s call for an account in the other country, which its home switch relays (
/link/v1/relay). - A switch’s call to a payment app whose home is the other country, which that app’s home switch forwards (
/link/v1/to-provider).
OCI-PAY-4 also fixes how money is converted, who charges the fee, and what each switch books when a cross-border payment completes.
OCI-PAY-4 does not repeat what other specs define. Addresses and how they resolve are in OCI-PAY-1. Participants, the OCI-Signature on every call, idempotency, the bank-facing API, the payment state machine and settlement positions are in OCI-PAY-2. The payment app’s own side is in OCI-PAY-3.
The reference implementation links two countries: India (IN, INR) and the United States (US, USD). This text uses them as its examples.
2. Conventions and terms
The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY and OPTIONAL are to be read as described in RFC 2119 and RFC 8174, and only when they appear in capitals. Every normative clause has an ID such as LINK-3.1.
| Term | Meaning |
|---|---|
| Switch | A country’s payments switch (OCI-PAY-2). Its participant id is switch:<CC>, where <CC> is its country code. |
| Peer switch | The other country’s switch, as seen from one switch. |
| Link | The /link/v1/* endpoints a switch serves for its peer, and the calls it makes to its peer’s. |
| Sending switch | The switch of the payer’s country in a cross-border payment. It holds the quote, charges the fee and forwards the payment. |
| Receiving switch | The switch of the payee’s country. It prices the quote, credits the payee’s bank and books the payee side. |
| Home switch | The one switch a payment app is registered with (OCI-PAY-3): the country of the app’s registry entry. |
| Provider | A payment app, as a participant (kind provider). |
| Money | {"value": "<decimal string>", "currency": "<ISO 4217>"}, at most two decimals (OCI-PAY-2). Switches keep integer minor units. |
| Minor unit | One hundredth of the currency unit (one paisa, one cent). |
3. Who may call the link
- LINK-3.1 Every
/link/v1/*call MUST carry anOCI-Signatureand MUST be verified as OCI-PAY-2 §4 requires, before the body is read. - LINK-3.2 A switch MUST accept a
/link/v1/*call only when the signer (iss) is an active participant ofkindswitchwhosecountryis not the receiving switch’s own country. Any other signer MUST get403 FORBIDDEN. A bank or a provider never calls the link. - LINK-3.3 A switch MUST NOT serve the link to its own country. A participant of
kindswitchwith the samecountryis refused under LINK-3.2. - LINK-3.4 A switch signs every link call with its own key, as
issswitch:<own CC>. It MUST NOT pass on a signature made by a bank or a provider. Where a call is made on someone’s behalf (§11, §12), the body names them, and the receiving switch checks that name against the registry. - LINK-3.5 The receiving switch MUST treat the body of a link call as a statement by the peer switch, not by the bank, app or person it describes. The checks in §6 to §12 are what stop a peer from speaking for parties it does not serve.
4. Finding the peer
- LINK-4.1 A switch finds its peer in the participant registry (OCI-1, OCI-PAY-2): the active participant of
kindswitchwhosecountryis not its own. The registry entry MUST carry the peer’scountry,base_url, and eitherjwks_urlor inline keys. - LINK-4.2 A deployment MAY configure the peer’s base URL (
PEER_SWITCH_URL). When set, it MUST be used in place of the registry’sbase_urlfor every link call, including/link/v1/to-provider. - LINK-4.3 The signed
htuis the peer’s base URL plus the path. The peer checks it against its own configured public URL (SELF_URL) plus the path it received. The two MUST be the same string, so a switch MUST be configured with the URL its peer uses to reach it. - LINK-4.4 A switch MUST send a payment, a quote, a lookup or a request for money to the peer only when the account behind the address is at a bank whose registry
countryis not its own (OCI-PAY-1 routing). - LINK-4.5 When the registry lists no peer switch, a call that needs one MUST fail with
503 PEER_UNAVAILABLE(routing, quotes) or404 NO_SWITCH(a relay, §11), and nothing MUST be sent. - LINK-4.6 A relay (§11) and a forward to a provider (§12) MUST go only to the peer whose
countryequals the country named in the call (the relay’scountry, or the provider’s home country). If they differ, nothing is sent.
5. Common rules
- LINK-5.1 Every link call is
POSTwith a JSON body, sent server to server. The receiving switch reads the body only after the signature check (LINK-3.1). - LINK-5.2 Addresses on the link are compared in lower case. A switch sends them in lower case.
- LINK-5.3 Money on the link uses the money format of OCI-PAY-2 §6: a decimal string with one to twelve integer digits and at most two decimals, greater than zero, in
INRorUSD. Anything else MUST be refused (422 INVALID_AMOUNT,422 UNKNOWN_CURRENCY). - LINK-5.4 A request body that does not match the call’s shape MUST be refused with
422 VALIDATION_ERROR. - LINK-5.5
POST /link/v1/paymentsandPOST /link/v1/collect-requestsMUST carry anIdempotency-Key. Without one the answer is400 IDEMPOTENCY_KEY_REQUIRED. OnPOST /link/v1/collect-requests/{id}/statusthe key is OPTIONAL. On/link/v1/relaythe key that travels is the payment app’s (§11). The rules for keys are those of OCI-PAY-2 §5, scoped to the calling switch and the path. - LINK-5.6 The sending switch MUST use the payment’s id as the
Idempotency-KeyofPOST /link/v1/payments, and the request’s id as the key ofPOST /link/v1/collect-requests. - LINK-5.7 Every link error uses the error body of OCI-PAY-2 (SW-13.1):
{"error": {"code": "<CODE>", "message": "<one sentence>"}}, with the HTTP status carrying the class. Codes are listed in §14.
6. Lookup
POST /link/v1/lookup answers “whose is this address?” for an address whose account is in the receiving switch’s country.
Request:
{ "address": "maya@bofa" }
Response (200):
{ "name": "Maya Brooks", "verified": true, "bank_name": "BofA", "assurance": "high" }
- LINK-6.1 The receiving switch MUST route the address as OCI-PAY-1 says. If the account is not at one of its own country’s banks, it MUST answer
404 ADDRESS_NOT_FOUND. - LINK-6.2 For an address its own bank issued, the receiving switch asks that bank (OCI-PAY-2). For an address a provider issued, the provider’s resolution answer is used, and the bank is not asked (OCI-PAY-1).
- LINK-6.3 The response MUST contain only
name,verified,bank_nameandassurance. None of them is null. It MUST NOT carry an account number or the provider’s account reference. - LINK-6.4 If the bank that holds the account does not answer, the receiving switch answers
503 BANK_UNAVAILABLE. If the address’s provider does not answer,503 PROVIDER_UNAVAILABLE. - LINK-6.5 The sending switch adds
address,country(the bank’s country from the registry) andcross_border: truebefore it answers its bank. A timeout or 5xx from the peer becomes503 PEER_UNAVAILABLE. Any other failure becomes404 ADDRESS_NOT_FOUND.
POST /link/v1/lookup Look up an address abroad · served by the switch
Who holds an address whose account is in this switch's country. Called by the other country's switch. Defined in LINK-6.1, LINK-6.2, LINK-6.3, LINK-6.4.
| Request | Type | Required | Meaning | Clause |
|---|---|---|---|---|
address | string | yes | A payment address, such as asha@sbi or maya@bofa, in lower case. Its account must be in this switch's country. | LINK-6.1 |
| Response | Type | Required | Meaning | Clause |
|---|---|---|---|---|
name | string | yes | The holder's name, as their bank or the issuing app holds it. | LINK-6.3 |
verified | boolean | yes | Whether the name comes from a checked identity. | LINK-6.3 |
bank_name | string | yes | The bank (or payment app) that answers for the address. | LINK-6.3 |
assurance | "low" | "substantial" | "high" | yes | How strongly the holder's identity was checked. | LINK-6.3 |
Errors
7. Exchange rate, fees and quotes
7.1 The rate
- LINK-7.1 Both switches use one fixed exchange rate, configured at each switch (
FX_USD_IN_INR,12.40by default): the number of INR in 1 USD. The same rate is used in both directions. - LINK-7.2 The rate is written on the wire as a decimal string with two decimals (
"12.40"), and always means INR per 1 USD, whichever way the money goes. - LINK-7.3 Both switches MUST be configured with the same rate. The receiving switch refuses a payment whose
ratestring differs from its own (LINK-8.6).
7.2 Converting
- LINK-7.4 Conversion works on integer minor units. USD to INR multiplies by the rate. INR to USD divides by it. The result MUST be rounded to a whole minor unit, half to even.
- LINK-7.5 An amount in the payer’s currency fixes the send side:
sendis the amount, andreceiveis its conversion. An amount in the payee’s currency fixes the receive side:receiveis the amount, andsendis its conversion. An amount in any other currency MUST be refused with422 CURRENCY_MISMATCH. - LINK-7.6 If either side converts to zero minor units, the quote MUST be refused with
422 AMOUNT_TOO_SMALL.
Examples at 12.40: INR 1240.00 sends USD 100.00. USD 100.00 to receive costs INR 1240.00. INR 0.31 is 2.5 cents, a tie, and rounds to USD 0.02.
7.3 The fee
- LINK-7.7 The sending switch charges a fixed fee in its own currency: INR 20.00 at the Indian switch, USD 1.62 at the US switch. The fee is a published figure per currency. It is not converted at the rate.
- LINK-7.8 The fee is on top of the send amount. The payer’s bank holds
total_debit = send + fee(OCI-PAY-2). The fee is booked to the sending switch’s own fee position (§9). It does not cross the link, and the receiving switch charges nothing.
7.4 Who quotes
- LINK-7.9 The receiving switch prices the quote, because it checks the payee. The sending switch adds its fee, issues the
quote_idand holds the quote. The link carries noquote_id. - LINK-7.10 The receiving switch keeps no state for a quote. It holds nothing and reserves nothing. The rate it prices with is fixed, so the same request always gets the same answer.
7.5 POST /link/v1/quotes
POST /link/v1/quotes Price the receiving side · served by the switch
What a cross-border payment sends and receives at the fixed rate, priced by the payee's switch, which keeps nothing. Called by the other country's switch. Defined in LINK-7.4, LINK-7.5, LINK-7.6, LINK-7.9, LINK-7.10, LINK-7.11, LINK-7.12, LINK-7.13.
| Request | Type | Required | Meaning | Clause |
|---|---|---|---|---|
from_address | string | The payer's address. It may be sent and is ignored. | LINK-7.11 | |
to_address | string | yes | The payee's address, whose account is in this switch's country. | LINK-7.12 |
amount | object | yes | The amount: in the payer's currency it fixes the send side, in the payee's currency the receive side. | LINK-7.5 |
amount.value | string | yes | A decimal string greater than zero, with at most two decimals, such as "250.00". Never a float. (pattern ^\d{1,12}(\.\d{1,2})?$) | LINK-5.3 |
amount.currency | "INR" | "USD" | yes | ISO 4217 code: INR or USD. | LINK-5.3 |
| Response | Type | Required | Meaning | Clause |
|---|---|---|---|---|
send | object | yes | What the payer's side sends, in the calling switch's currency. | LINK-7.13 |
send.value | string | yes | A decimal string greater than zero, with at most two decimals, such as "250.00". Never a float. (pattern ^\d{1,12}(\.\d{1,2})?$) | LINK-5.3 |
send.currency | "INR" | "USD" | yes | ISO 4217 code: INR or USD. | LINK-5.3 |
receive | object | yes | What the payee receives, in this switch's currency. | LINK-7.13 |
receive.value | string | yes | A decimal string greater than zero, with at most two decimals, such as "250.00". Never a float. (pattern ^\d{1,12}(\.\d{1,2})?$) | LINK-5.3 |
receive.currency | "INR" | "USD" | yes | ISO 4217 code: INR or USD. | LINK-5.3 |
rate | string | yes | The exchange rate: INR per 1 USD, as a decimal string with two decimals, such as "12.40". (pattern ^\d+\.\d{2}$) | LINK-7.2 |
payee_name | string, null | yes | The payee's name, from the same check as a lookup. | LINK-7.12 |
Errors
403 FORBIDDEN(LINK-3.2)422 VALIDATION_ERROR(LINK-5.4)422 INVALID_AMOUNT(LINK-5.3)422 UNKNOWN_CURRENCY(LINK-5.3)404 ADDRESS_NOT_FOUND(LINK-7.12)422 NOT_CROSS_BORDER(LINK-7.12)422 CURRENCY_MISMATCH(LINK-7.5)422 AMOUNT_TOO_SMALL(LINK-7.6)503 BANK_UNAVAILABLE(LINK-6.4)503 PROVIDER_UNAVAILABLE(LINK-6.4)
Request (the sending switch is IN; the payee’s account is in the US):
{ "to_address": "maya@bofa", "amount": { "value": "20.00", "currency": "USD" } }
Response (200):
{
"send": { "value": "248.00", "currency": "INR" },
"receive": { "value": "20.00", "currency": "USD" },
"rate": "12.40",
"payee_name": "Maya Brooks"
}
- LINK-7.11 The body is
{to_address, amount}. Afrom_addressMAY be present and MUST be ignored. - LINK-7.12 If the payee’s account is not in the receiving switch’s country, it MUST answer
422 NOT_CROSS_BORDER. If the address has no account,404 ADDRESS_NOT_FOUND. It checks the payee as for a lookup (§6). - LINK-7.13 The receiving switch prices with its peer’s currency as the send currency and its own as the receive currency (LINK-7.5), and answers
send,receive,rateandpayee_name. - LINK-7.14 The sending switch MUST check that
sendis in its own currency andreceivein the peer’s. Otherwise it MUST refuse the quote with502 PEER_REJECTED. - LINK-7.15 The sending switch then stores the quote with its fee and an expiry of 600 seconds, and answers its bank
{quote_id, send, receive, rate, fee, total_debit, expires_at}(OCI-PAY-2). Therateit stores and answers is its own configured rate. - LINK-7.16 When the peer does not answer, the sending switch answers
503 PEER_UNAVAILABLE. When the peer refuses, it passes the peer’s code on, with the peer’s status if that was 404 or 422, else502. - LINK-7.17 A quote is used by one payment (OCI-PAY-2). If that payment fails, the sending switch MUST release the quote, so the payer may pay with it again before it expires.
8. Payments
POST /link/v1/payments Forward a cross-border payment · served by the switch
The sending switch has claimed the quote; the receiving switch checks the payment, credits the payee's bank and answers its state. Called by the sending switch (the payer's country). Defined in LINK-5.5, LINK-5.6, LINK-8.2, LINK-8.5, LINK-8.6, LINK-8.7, LINK-8.8, LINK-8.9, LINK-8.10, LINK-8.11, LINK-8.12, LINK-8.13, LINK-8.15, LINK-8.16.
| Request | Type | Required | Meaning | Clause |
|---|---|---|---|---|
id | string, uuid | yes | The payment's id (a UUID), the same on both switches for its whole life; also the Idempotency-Key. | LINK-8.3 |
from_address | string | yes | The payer's address; its account must be in the calling switch's country. | LINK-8.6 |
from_name | string, null | The payer's name, as their bank or app holds it. | LINK-8.2 | |
to_address | string | yes | The payee's address; its account must be in this switch's country. | LINK-8.5 |
send | object | yes | What the payer's side sends, in the calling switch's currency. | LINK-8.7 |
send.value | string | yes | A decimal string greater than zero, with at most two decimals, such as "250.00". Never a float. (pattern ^\d{1,12}(\.\d{1,2})?$) | LINK-5.3 |
send.currency | "INR" | "USD" | yes | ISO 4217 code: INR or USD. | LINK-5.3 |
receive | object | yes | What the payee receives, in this switch's currency. | LINK-8.7 |
receive.value | string | yes | A decimal string greater than zero, with at most two decimals, such as "250.00". Never a float. (pattern ^\d{1,12}(\.\d{1,2})?$) | LINK-5.3 |
receive.currency | "INR" | "USD" | yes | ISO 4217 code: INR or USD. | LINK-5.3 |
rate | string | yes | The exchange rate: INR per 1 USD, as a decimal string with two decimals, such as "12.40". (pattern ^\d+\.\d{2}$) | LINK-8.7 |
note | string, null | Free text from the payer. (at most 140 characters) | LINK-8.2 | |
collect_request_id | string, null, uuid | The request for money this payment pays, when it pays one. | LINK-8.9 |
| Response | Type | Required | Meaning | Clause |
|---|---|---|---|---|
id | string, uuid | yes | The payment's id. | LINK-8.3 |
status | "completed" | "pending" | "failed" | yes | The wire status: pending while the switch's state is received or credited. | LINK-8.16 |
state | "received" | "credited" | "completed" | "failed" | "reversed" | yes | The receiving switch's own state of the payment. | LINK-8.15 |
failure_reason | string, null | yes | Why it failed, when status is failed. | LINK-8.16 |
direction | "inbound" | yes | Always inbound: the receiving switch's side of the payment. | LINK-8.15 |
from_address | string | yes | The payer's address. | LINK-5.2 |
to_address | string | yes | The payee's address. | LINK-5.2 |
to_name | string, null | yes | The payee's name. | LINK-8.15 |
amount | object | yes | The send amount, in the calling switch's currency. | LINK-8.15 |
amount.value | string | yes | A decimal string greater than zero, with at most two decimals, such as "250.00". Never a float. (pattern ^\d{1,12}(\.\d{1,2})?$) | LINK-5.3 |
amount.currency | "INR" | "USD" | yes | ISO 4217 code: INR or USD. | LINK-5.3 |
receive | object | yes | What the payee receives, in this switch's currency. | LINK-8.15 |
receive.value | string | yes | A decimal string greater than zero, with at most two decimals, such as "250.00". Never a float. (pattern ^\d{1,12}(\.\d{1,2})?$) | LINK-5.3 |
receive.currency | "INR" | "USD" | yes | ISO 4217 code: INR or USD. | LINK-5.3 |
fee | null | yes | Always null: the receiving switch charges nothing. | LINK-7.8 |
rate | string | yes | The exchange rate: INR per 1 USD, as a decimal string with two decimals, such as "12.40". (pattern ^\d+\.\d{2}$) | LINK-8.15 |
note | string, null | yes | Free text from the payer. (at most 140 characters) | LINK-8.15 |
collect_request_id | string, null, uuid | yes | The request for money this payment pays, when it pays one. | LINK-8.15 |
created_at | string, date-time | yes | When the receiving switch recorded it (ISO 8601, UTC). | LINK-8.15 |
completed_at | string, null, date-time | yes | When it finished, once it has. | LINK-8.15 |
Errors
400 IDEMPOTENCY_KEY_REQUIRED(LINK-5.5)403 FORBIDDEN(LINK-3.2)422 VALIDATION_ERROR(LINK-5.4)422 INVALID_AMOUNT(LINK-5.3)422 UNKNOWN_CURRENCY(LINK-5.3)403 ADDRESS_NOT_OWNED(LINK-8.6)404 ADDRESS_NOT_FOUND(LINK-8.5)422 RATE_MISMATCH(LINK-8.7)422 RATE_MISMATCH(LINK-8.8)404 REQUEST_NOT_FOUND(LINK-8.9)422 REQUEST_MISMATCH(LINK-8.9)409 REQUEST_NOT_PAYABLE(LINK-8.9)410 REQUEST_EXPIRED(LINK-8.9)409 PAYMENT_ID_TAKEN(LINK-8.13)422 IDEMPOTENCY_KEY_REUSED(LINK-8.4)
8.1 Forwarding (the sending switch)
A bank or a provider starts a cross-border payment at its own switch with a quote_id (OCI-PAY-2). The sending switch records it as outbound and forwards it.
-
LINK-8.1 The sending switch forwards a payment to
POST /link/v1/paymentsonly after it has claimed the quote, and, for a provider’s payment, after the payer’s bank has held the money (OCI-PAY-2, OCI-PAY-3). -
LINK-8.2 The body MUST be:
{ "id": "<payment id, UUID>", "from_address": "asha@sbi", "from_name": "Asha Rao", "to_address": "maya@bofa", "send": { "value": "248.00", "currency": "INR" }, "receive": { "value": "20.00", "currency": "USD" }, "rate": "12.40", "note": null, "collect_request_id": null }id,from_address,to_address,send,receiveandrateare REQUIRED.from_name,note(at most 140 characters) andcollect_request_idare OPTIONAL. The fee, the quote id, the payer’s account and the PIN MUST NOT be sent. -
LINK-8.3 The payment keeps the same
idon both switches for its whole life. -
LINK-8.4 Every repeat of the forward MUST send the same body bytes with the same
Idempotency-Key(LINK-5.6). A repeat with different bytes is refused by the peer (IDEMPOTENCY_KEY_REUSED) and leaves the payment unknown (§13).
8.2 Creating the inbound payment (the receiving switch)
- LINK-8.5 The receiving switch MUST route
to_address(OCI-PAY-1). If its account is not at one of its own country’s banks, it MUST answer404 ADDRESS_NOT_FOUND. - LINK-8.6 The receiving switch MUST route
from_addresstoo. If that account is in its own country, or the switch it routes to is not the calling switch, it MUST answer403 ADDRESS_NOT_OWNED. A peer can only send money from addresses whose accounts are in its own country. - LINK-8.7
sendMUST be in the peer’s currency,receivein the receiving switch’s own currency, andrateMUST equal the receiving switch’s own rate string. Otherwise it MUST answer422 RATE_MISMATCH. - LINK-8.8 The amounts MUST agree with the rate. The payment is accepted when
receiveequalssendconverted (a fixed-send quote) orsendequalsreceiveconverted back (a fixed-receive quote), by LINK-7.4. Otherwise it MUST answer422 RATE_MISMATCH. - LINK-8.9 If
collect_request_idis set, the receiving switch MUST attach the payment to its own copy of that request (§10) in the same transaction that records the payment. The request’s payer must be the calling switch, its parties must be the payment’s, and its amount must equalreceivein the receiving switch’s currency. The errors are those of OCI-PAY-2 §13:404 REQUEST_NOT_FOUND,422 REQUEST_MISMATCH,409 REQUEST_NOT_PAYABLE,410 REQUEST_EXPIRED. - LINK-8.10 The receiving switch records the payment as
inbound, with the calling switch as the payer participant and the payee’s bank as the payee participant, and then runs it (§9): it credits the payee’s bank in its own currency withreceive, and passes the conversion to the bank asfx: {rate, send, receive}andfrom_country.
8.3 Repeats
- LINK-8.11 A repeat with the same
Idempotency-Keyand the same body MUST return the first answer. If the first answer was still pending (receivedorcredited), the receiving switch MUST try to move the payment forward again and answer its new state (OCI-PAY-2). - LINK-8.12 A repeat with a new key but the same
idMUST continue the existing payment, not make a second one, when the existing payment isinbound, from the same calling switch, with the samesend,receiveandto_address. It answers the payment’s current state. - LINK-8.13 The same
idwith different parties or amounts MUST be refused with409 PAYMENT_ID_TAKEN. It is never merged. - LINK-8.14 A payee’s bank is credited at most once for one payment id, however many times the peer forwards it.
8.4 The answer
- LINK-8.15 The receiving switch answers
200with its payment record (OCI-PAY-2):id,status,state,failure_reason,direction(inbound),from_address,to_address,to_name,amount(the send amount),receive,fee(null),rate,note,collect_request_id,created_atandcompleted_at. - LINK-8.16
statusis the wire status:completed,pending(the switch’s state isreceivedorcredited), orfailedwith afailure_reason. A failed payment is a200answer, not an error. - LINK-8.17 The sending switch MUST treat the payment as credited only when the answer is
200withstatuscompleted.200withfailedfails the payment with the peer’sfailure_reason(PEER_FAILEDif none). Any other200leaves it pending. Errors are classified by §13. - LINK-8.18 When the sending switch fails a payment, it releases the quote (LINK-7.17) and any request for money it was paying, and, for a provider’s payment, tells the payer’s bank to release the hold (OCI-PAY-2).
9. State machines and positions
Each switch runs its own record of the payment through the state machine of OCI-PAY-2 §9: received, then credited, then completed or failed. reversed exists in the record, but nothing produces it.
| Step | Sending switch (outbound) | Receiving switch (inbound) |
|---|---|---|
| Recorded | received, quote claimed | received |
| Credit | credited when the peer answers completed | credited when its payee’s bank confirms the credit |
| Booked | completed: positions booked | completed: positions booked, then the payee’s app is told (OCI-PAY-3) |
| Definite no | failed: quote released | failed |
| No answer | stays received | stays received |
-
LINK-9.1 The receiving switch MUST complete its own record, and book its positions, before it answers
completedto the peer. The sending switch MUST NOT complete its record before that answer. -
LINK-9.2 Positions are booked once, when a record moves from
creditedtocompleted. Every payment’s movements MUST sum to zero in each currency. A switch MUST refuse to book a set that does not. -
LINK-9.3 A positive position means the switch owes that participant. The peer switch’s position is named
link:<peer CC>. The fee position isfees:<own CC>. -
LINK-9.4 The sending switch books, in its own currency:
Participant Amount Kind the payer’s bank − send principal link:<peer CC>+ send principal the payer’s bank − fee fee fees:<own CC>+ fee fee -
LINK-9.5 The receiving switch books, in its own currency:
Participant Amount Kind the payee’s bank + receive principal link:<peer CC>− receive principal -
LINK-9.6 So the sending switch owes its peer the send amount in its own currency, and the receiving switch is owed the receive amount in its own currency. At the fixed rate these are the same value.
-
LINK-9.7 Each switch settles its own positions in its own cycles (OCI-PAY-2 §12). A cycle’s result shows the link net, its direction (
switch_owes_peerorpeer_owes_switch), and its value in the peer’s currency at the fixed rate. Nothing about settlement crosses the link. How the two NPCs pay each other the link net is outside this spec.
10. Requests for money
A payee in one country can ask a payer in the other for money. The payee’s switch keeps the request, and the payer’s switch keeps a copy with the same id.
10.1 POST /link/v1/collect-requests
POST /link/v1/collect-requests Pass on a request for money · served by the switch
A payee in the calling switch's country asks a payer in this country for money; this switch keeps a copy and delivers it. Called by the payee's switch. Defined in LINK-5.5, LINK-5.6, LINK-10.1, LINK-10.2, LINK-10.3, LINK-10.4, LINK-10.5, LINK-10.6.
| Request | Type | Required | Meaning | Clause |
|---|---|---|---|---|
id | string, uuid | yes | The request's id (a UUID), the same on both switches; also the Idempotency-Key. | LINK-10.1 |
payee_address | string | yes | The address asking for the money; its account must be in the calling switch's country. | LINK-10.2 |
payee_name | string, null | The payee's name, so the payer can be warned about an unknown payee. | LINK-10.1 | |
payee_assurance | "low" | "substantial" | "high" | "null" | How strongly the payee's identity was checked. | LINK-10.1 | |
payee_country | string | yes | The payee's country: the calling switch's country code. (pattern ^[A-Z]{2}$) | LINK-10.1 |
payer_address | string | yes | The address being asked to pay; its account must be in this switch's country. | LINK-10.4 |
amount | object | yes | The amount asked for, in the payee's currency (the calling switch's). | LINK-10.3 |
amount.value | string | yes | A decimal string greater than zero, with at most two decimals, such as "250.00". Never a float. (pattern ^\d{1,12}(\.\d{1,2})?$) | LINK-5.3 |
amount.currency | "INR" | "USD" | yes | ISO 4217 code: INR or USD. | LINK-5.3 |
note | string, null | Free text from the payee. | LINK-10.1 | |
expires_at | string, date-time | yes | When the request stops being payable: in the future and at most 30 days ahead. | LINK-10.5 |
created_at | string, date-time | When the payee's switch made it. It may be sent and is ignored. | LINK-10.1 |
| Response | Type | Required | Meaning | Clause |
|---|---|---|---|---|
id | string, uuid | yes | The request's id. | |
status | "pending" | "approved" | "declined" | "cancelled" | "expired" | "paid" | yes | The request's status at this switch; pending for a new request. | LINK-10.1 |
payee_address | string | yes | The address asking for the money. | LINK-5.2 |
payer_address | string | yes | The address being asked to pay. | LINK-5.2 |
amount | object | yes | The amount asked for, in the payee's currency. | LINK-10.3 |
amount.value | string | yes | A decimal string greater than zero, with at most two decimals, such as "250.00". Never a float. (pattern ^\d{1,12}(\.\d{1,2})?$) | LINK-5.3 |
amount.currency | "INR" | "USD" | yes | ISO 4217 code: INR or USD. | LINK-5.3 |
expires_at | string, date-time | yes | When the request stops being payable. | LINK-10.5 |
Errors
400 IDEMPOTENCY_KEY_REQUIRED(LINK-5.5)403 FORBIDDEN(LINK-3.2)422 VALIDATION_ERROR(LINK-5.4)422 INVALID_AMOUNT(LINK-5.3)422 UNKNOWN_CURRENCY(LINK-5.3)403 ADDRESS_NOT_OWNED(LINK-10.2)422 CURRENCY_MISMATCH(LINK-10.3)404 PAYER_NOT_FOUND(LINK-10.4)422 INVALID_EXPIRY(LINK-10.5)409 REQUEST_ID_TAKEN(LINK-10.5)503 DELIVERY_FAILED(LINK-10.6)422 REQUEST_REJECTED(LINK-10.6)
Request (the payee’s switch is US):
{
"id": "<request id, UUID>",
"payee_address": "maya@bofa",
"payee_name": "Maya Brooks",
"payee_assurance": "high",
"payee_country": "US",
"payer_address": "asha@sbi",
"amount": { "value": "20.00", "currency": "USD" },
"note": "dinner",
"expires_at": "2026-11-29T12:00:00Z",
"created_at": "2026-11-28T12:00:00Z"
}
Response (200): {id, status, payee_address, payer_address, amount, expires_at}.
- LINK-10.1 The payee’s switch sends the request flat (not wrapped), with the request’s id as the
Idempotency-Key.id,payee_address,payee_country,payer_address,amountandexpires_atare REQUIRED. The other fields are OPTIONAL.created_atis ignored. - LINK-10.2 The payer’s switch MUST check that
payee_addressroutes to an account in the other country through the calling switch. Otherwise403 ADDRESS_NOT_OWNED. - LINK-10.3
amountMUST be in the payee’s currency, which is the calling switch’s currency. Otherwise422 CURRENCY_MISMATCH. Both switches keep the request in that currency. - LINK-10.4
payer_addressMUST route to an account in the payer’s switch’s own country. Otherwise404 PAYER_NOT_FOUND. - LINK-10.5
expires_atMUST be in the future and no more than 30 days ahead. Otherwise422 INVALID_EXPIRY. A second request with the same id is409 REQUEST_ID_TAKEN. - LINK-10.6 The payer’s switch delivers its copy to whoever answers for the payer’s address: the provider that issued it, else the payer’s bank (and the bank’s own app, if it has one) (OCI-PAY-2, OCI-PAY-3). If delivery fails, it MUST delete its copy and answer an error:
503 DELIVERY_FAILEDwhen nobody answered,404 PAYER_NOT_FOUNDwhen the payer’s side said 404, else422 REQUEST_REJECTED. - LINK-10.7 When the link call fails, the payee’s switch MUST delete its own record too, and answer its bank with the same rule (LINK-10.6). A request that nobody can see is not kept.
10.2 Paying a request across the link
- LINK-10.8 The payer pays with a cross-border payment that carries
collect_request_id(§8). Because the request is in the payee’s currency, the payer’s quote MUST fix the receive side (LINK-7.5), and the payment’sreceiveMUST equal the request’s amount. - LINK-10.9 Each switch attaches the payment to its own copy (LINK-8.9) and marks it
paidwhen its own record of the payment completes.paiddoes not travel as a status change. The payee’s switch tells the payee’s bank or app; the payer’s switch does not tell the peer.
10.3 POST /link/v1/collect-requests/{id}/status
POST /link/v1/collect-requests/{request_id}/status Change a request across the link · served by the switch
The calling switch's party approved, declined, cancelled or expired a request; this switch records it and tells its own party. Called by the other party's switch (payer's or payee's). Defined in LINK-10.10, LINK-10.11, LINK-10.12, LINK-10.13, LINK-10.14.
| Request | Type | Required | Meaning | Clause |
|---|---|---|---|---|
status | "approved" | "declined" | "cancelled" | "expired" | yes | The new status: only the payer approves or declines, only the payee cancels, and expired only once the request has lapsed. | LINK-10.10 |
report | boolean | True when the payer declines and reports the request as unwanted; counts only with declined. Defaults to false. | LINK-10.10 |
| Response | Type | Required | Meaning | Clause |
|---|---|---|---|---|
id | string, uuid | yes | The request's id. | |
status | "approved" | "declined" | "cancelled" | "expired" | yes | The status now recorded. | LINK-10.10 |
relayed | boolean | yes | Whether this switch's own party (bank or app) accepted the change; false on a repeat of the current status. | LINK-10.14 |
Errors
403 FORBIDDEN(LINK-3.2)422 VALIDATION_ERROR(LINK-5.4)422 INVALID_STATUS(LINK-10.10)404 REQUEST_NOT_FOUND(LINK-10.11)409 NOT_ALLOWED(LINK-10.12)409 REQUEST_CLOSED(LINK-10.12)409 REQUEST_BEING_PAID(LINK-10.12)410 REQUEST_EXPIRED(LINK-10.12)
Request: {"status": "declined", "report": true}. Response (200): {"id": "<id>", "status": "declined", "relayed": true}.
- LINK-10.10
statusMUST beapproved,declined,cancelledorexpired. Otherwise422 INVALID_STATUS.reportis OPTIONAL (defaultfalse) and counts only withdeclined. - LINK-10.11 The calling switch speaks for its own side of the request: for the payer when it holds the payer’s account, for the payee when it holds the payee’s. The receiving switch MUST apply the same role rules as for a bank (OCI-PAY-2): only the payer approves or declines, only the payee cancels, and
expiredonly once the request has lapsed. A request not known with the caller as a party is404 REQUEST_NOT_FOUND. - LINK-10.12 A change the rules do not allow is
409 NOT_ALLOWED, or409 REQUEST_CLOSEDwhen the request is already closed. Declining, cancelling or expiring a request that a payment is paying is409 REQUEST_BEING_PAID. Approving a lapsed request is410 REQUEST_EXPIRED. - LINK-10.13 A repeat of the current status MUST answer
200withrelayed: falseand change nothing. - LINK-10.14 The receiving switch records the change, then passes it to its own party (bank or app), and answers
relayedas whether that party accepted it. - LINK-10.15 The sending switch records the change in its own copy before it calls the link. The link call is best effort: if it fails, the local change stands, and the sending switch answers its bank
relayed: false.
11. Relay: a payment app’s call for the other country
A payment app calls only its home switch (OCI-PAY-3). To work on an account in the other country, it asks its home switch to pass the call on. The other country’s switch runs it as if the app had called it there. The payment, the request for money or the bank connection is kept by the switch of the account’s country, as before.
app -- POST /v1/relay {country, method, path, body} --> home switch
home -- POST /link/v1/relay {provider, method, path, body} --> the account's switch
11.1 At the home switch
POST /v1/relay Pass a call to the other country's switch · served by the switch
The home switch passes the app's call to the switch of the account's country and returns that switch's answer unchanged. Called by a payment app registered with this switch. Defined in PSP-6.1, PSP-6.2, PSP-6.3, PSP-6.4, PSP-6.5, PSP-6.6, PSP-6.7, PSP-6.8.
| Request | Type | Required | Meaning | Clause |
|---|---|---|---|---|
country | string | yes | The account's country, two letters: the switch to pass the call to. Never the home country. (pattern ^[A-Za-z]{2}$) | PSP-6.3 |
method | "GET" | "POST" | The method of the call as the app would make it there. | PSP-6.8 | |
path | string | yes | The path of the call there, such as /v1/payments; only the paths PSP-6.2 lists. (at most 200 characters; at least 4) | PSP-6.2 |
body | object, null | The body the call would carry; null for a GET. | PSP-6.8 |
| Response | Type | Required | Meaning | Clause |
|---|
Errors
- LINK-11.1 Only a provider registered with this switch may call
POST /v1/relay. Any other caller MUST get403 FORBIDDEN. (The app’s request is in OCI-PAY-3.) - LINK-11.2 If
countryis the home switch’s own country, it MUST answer422 NOT_RELAYED. If the call may not be relayed (LINK-11.6), it MUST answer404 NOT_RELAYEDbefore anything is sent. If no peer switch is registered forcountry, it MUST answer404 NO_SWITCH. - LINK-11.3 The home switch sends
POST /link/v1/relaywith body{"provider": "<the app's participant id>", "method": "GET" | "POST", "path": "<path>", "body": <object or null>}.provideris the authenticated caller, never a value the app supplied. The app’sIdempotency-Keyheader MUST be sent unchanged. - LINK-11.4 The home switch keeps no record of the call. It MUST answer the app with the peer’s
2xxbody unchanged, as200. When the peer answered with an error body, the home switch MUST answer with the same HTTP status, code and message. When the peer did not answer, or answered without an error body, it MUST answer503 PEER_UNAVAILABLE.
11.2 At the account’s switch
POST /link/v1/relay Relay a payment app's call · served by the switch
Runs a call a payment app registered with the peer switch makes for an account in this country, as if the app had called here directly. Called by a payment app's home switch, on the app's behalf. Defined in LINK-11.3, LINK-11.5, LINK-11.6, LINK-11.7, LINK-11.8, LINK-11.9.
| Request | Type | Required | Meaning | Clause |
|---|---|---|---|---|
provider | string | yes | The payment app's participant id: the home switch's authenticated caller, never a value the app supplied. (at most 100 characters; at least 1) | LINK-11.3 |
method | "GET" | "POST" | yes | The relayed call's HTTP method. | LINK-11.6 |
path | string | yes | The relayed call's whole path, one of the calls LINK-11.6 lists, such as /v1/payments. (at most 200 characters; at least 4) | LINK-11.6 |
body | object, null | yes | The relayed call's body, validated as the direct call's body; null for a GET. | LINK-11.7 |
| Response | Type | Required | Meaning | Clause |
|---|
Errors
-
LINK-11.5 The receiving switch MUST check that
provideris an active participant ofkindproviderwhosecountry(its home) is the calling switch’s country. Otherwise403 FORBIDDEN. -
LINK-11.6 Only these calls may be relayed, matched exactly on method and the whole path. Anything else MUST be refused with
404 NOT_RELAYED.Method Path POST /v1/connect/accounts,/v1/connect/link,/v1/connect/unlink,/v1/balancePOST /v1/lookup,/v1/quotes,/v1/payments,/v1/collect-requestsPOST /v1/collect-requests/{id}/statusGET /v1/payments/{id} -
LINK-11.7 The receiving switch MUST validate
bodyas the direct call’s body (422 VALIDATION_ERROR), and MUST run the call with the provider as the caller, under every rule the direct call has at that switch. The home-switch rule of OCI-PAY-3 §4 is the one check it skips, because the call came through the provider’s home switch. -
LINK-11.8 The receiving switch MUST apply the direct call’s idempotency rules (keys required on payments and requests for money, optional on quotes and status changes), with the travelling key, scoped to the provider, the call and the relay. The request hash is taken over
bodyas canonical JSON: keys sorted, no spaces. So the same body hashes the same at both switches. -
LINK-11.9 The receiving switch answers what the direct call would answer: the
2xxbody, or the error.
12. To a provider: a switch’s call to an app whose home is the other country
A switch reaches a payment app only through the app’s home switch. When the switch must call an app whose home is the other country (to resolve an address the app issued, to say money arrived, to deliver a request for money, or to pass a status change; OCI-PAY-3), it asks the peer to forward the call.
POST /link/v1/to-provider Forward a call to a payment app · served by the switch
Passes a switch's call to a payment app registered here, signed by this switch, and hands back the app's answer as given. Called by the other country's switch, for a payment app whose home is here. Defined in LINK-12.1, LINK-12.2, LINK-12.3, LINK-12.4, LINK-12.5.
| Request | Type | Required | Meaning | Clause |
|---|---|---|---|---|
provider | string | yes | The payment app's participant id; it must be registered with this switch. (at most 100 characters; at least 1) | LINK-12.3 |
path | string | yes | The path on the app to call, under /switch/v1/. (pattern ^/switch/v1/[A-Za-z0-9/_-]+$; at most 200 characters) | LINK-12.2 |
body | object | yes | The body to send the app. | LINK-12.2 |
| Response | Type | Required | Meaning | Clause |
|---|
Errors
- LINK-12.1 A switch MUST call a provider directly only when the provider’s home is its own country. Otherwise it MUST send
POST /link/v1/to-providerto the peer of the provider’s home country, with body{"provider": "<participant id>", "path": "<path>", "body": <object>}. If no peer is registered for that country, the call is unknown (§13) and nothing is sent. - LINK-12.2
pathMUST match^/switch/v1/[A-Za-z0-9/_-]+$and be at most 200 characters.bodyis REQUIRED and is an object. Otherwise422 VALIDATION_ERROR. - LINK-12.3 The receiving switch MUST check that
provideris an active participant ofkindproviderregistered with it: itscountryis the receiving switch’s own. Otherwise404 PROVIDER_NOT_HERE. - LINK-12.4 The receiving switch forwards
POST <provider base_url><path>withbody, signed by itself (issswitch:<own CC>). The app sees a call from its home switch only. - LINK-12.5 If the app answered, the receiving switch MUST answer with the app’s HTTP status and the app’s JSON body unchanged (
{}if the body was not a JSON object). If the app did not answer, it MUST answer503 PROVIDER_UNAVAILABLE. - LINK-12.6 The calling switch classifies the answer as if the app had answered it directly (§13).
13. Timeouts, retries and ambiguity
-
LINK-13.1 A switch waits at most 7 seconds for its peer (
LINK_TIMEOUT_SECONDS). It waits at most 4 seconds for a bank or for an app it calls directly, including the forwarded leg of §12 (BANK_TIMEOUT_SECONDS). A receiving switch SHOULD wait for its own banks and apps for less time than its peer waits for it. -
LINK-13.2 Every answer to a link call is one of three kinds:
Kind What counts ok any 2xxrejected (a definite no) any 4xx, except the three belowunknown a timeout, a transport error, any 5xx, any other status, and409 REQUEST_IN_PROGRESS,409 PAYMENT_ID_TAKEN,422 IDEMPOTENCY_KEY_REUSED -
LINK-13.3
409 REQUEST_IN_PROGRESS,409 PAYMENT_ID_TAKENand422 IDEMPOTENCY_KEY_REUSEDsay “I already have this”, not “no”. The payment may be running or done at the peer. A switch MUST NOT fail a payment on them. -
LINK-13.4 A payment whose forward is unknown MUST stay
receivedat the sending switch, keep its quote and any request for money it pays, and answerpending. A rejected forward fails it, with the peer’s error code asfailure_reason. -
LINK-13.5 Neither switch retries on a timer. A pending cross-border payment moves forward only when it is driven again: the payer’s bank (or app) repeats its payment call with the same
Idempotency-Key, or an operator retries it (OCI-PAY-2). Each drive repeats the forward under LINK-8.4, and the peer moves its own record forward under LINK-8.11. -
LINK-13.6 There is no link call to read a payment’s state. The sending switch learns the peer’s state only by repeating the forward.
-
LINK-13.7 An unknown answer to a lookup or quote is
503 PEER_UNAVAILABLEto the bank. An unknown answer to a request for money deletes it (LINK-10.7). An unknown answer to a status change leavesrelayed: false.
14. Errors
Errors use the body of LINK-5.7. These are the codes a switch answers on the link, or turns a link answer into.
| Status | Code | When |
|---|---|---|
| 400 | IDEMPOTENCY_KEY_REQUIRED, IDEMPOTENCY_KEY_INVALID | LINK-5.5 |
| 401 | SIGNATURE_REQUIRED, SIGNATURE_INVALID, SIGNATURE_EXPIRED, UNKNOWN_PARTICIPANT | the signature checks of OCI-PAY-2 §4 |
| 403 | FORBIDDEN | LINK-3.2, LINK-11.1, LINK-11.5 |
| 403 | ADDRESS_NOT_OWNED | LINK-8.6, LINK-10.2 |
| 404 | ADDRESS_NOT_FOUND, PAYER_NOT_FOUND, REQUEST_NOT_FOUND | §6, §7, §8, §10 |
| 404 | NOT_RELAYED, NO_SWITCH, PROVIDER_NOT_HERE | §11, §12 |
| 409 | PAYMENT_ID_TAKEN, REQUEST_ID_TAKEN, REQUEST_IN_PROGRESS | LINK-8.13, LINK-10.5, OCI-PAY-2 |
| 409 | REQUEST_NOT_PAYABLE, REQUEST_BEING_PAID, REQUEST_CLOSED, NOT_ALLOWED | §10 |
| 410 | REQUEST_EXPIRED | §10 |
| 422 | VALIDATION_ERROR, INVALID_ADDRESS, INVALID_AMOUNT, UNKNOWN_CURRENCY | LINK-5.3, LINK-5.4 |
| 422 | NOT_CROSS_BORDER, CURRENCY_MISMATCH, AMOUNT_TOO_SMALL, RATE_MISMATCH | §7, §8, §10 |
| 422 | IDEMPOTENCY_KEY_REUSED, INVALID_EXPIRY, INVALID_STATUS, REQUEST_MISMATCH, NOT_RELAYED | §5, §8, §10, §11 |
| 502 | PEER_REJECTED | LINK-7.14, LINK-7.16 |
| 503 | PEER_UNAVAILABLE, BANK_UNAVAILABLE, PROVIDER_UNAVAILABLE, DELIVERY_FAILED, TRUST_UNAVAILABLE | the other side, or the registry, did not answer |
- LINK-14.1 A switch MUST NOT put an account number, a PIN, a token, or any detail about a person beyond what the call is about into an error message.
- LINK-14.2 A relay (§11) and a forward to a provider (§12) pass the other side’s error on as it was given. Every other link answer is the switch’s own.
15. Worked example
Asha Rao (asha@sbi, at SBI, IN) pays Maya Brooks (maya@bofa, at BofA, US) USD 20.00. The rate is 12.40.
1. Quote. SBI asks its switch:
bank:sbi -> switch:IN POST /v1/quotes
{ "from_address": "asha@sbi", "to_address": "maya@bofa", "amount": { "value": "20.00", "currency": "USD" } }
maya@bofa routes to the US, so the Indian switch asks the US switch to price it:
switch:IN -> switch:US POST /link/v1/quotes
{ "to_address": "maya@bofa", "amount": { "value": "20.00", "currency": "USD" } }
The US switch asks BofA who maya@bofa is. The amount is in USD, its own currency, so it fixes the receive side: 2000 cents × 12.40 = 24800 paise.
{ "send": { "value": "248.00", "currency": "INR" }, "receive": { "value": "20.00", "currency": "USD" },
"rate": "12.40", "payee_name": "Maya Brooks" }
The Indian switch adds its fee and holds the quote for 10 minutes:
{ "quote_id": "5b0e6c1e-7a51-4d0e-9f3a-2c8b1d4e6f70",
"send": { "value": "248.00", "currency": "INR" }, "receive": { "value": "20.00", "currency": "USD" },
"rate": "12.40", "fee": { "value": "20.00", "currency": "INR" },
"total_debit": { "value": "268.00", "currency": "INR" }, "expires_at": "2026-11-28T12:10:00Z" }
2. Payment. SBI holds INR 268.00 from Asha’s account and sends the payment, with an Idempotency-Key:
bank:sbi -> switch:IN POST /v1/payments
{ "from_address": "asha@sbi", "from_name": "Asha Rao", "to_address": "maya@bofa",
"amount": { "value": "248.00", "currency": "INR" }, "quote_id": "5b0e6c1e-7a51-4d0e-9f3a-2c8b1d4e6f70" }
The Indian switch claims the quote, records payment 9d2f… as outbound and received, and forwards it:
switch:IN -> switch:US POST /link/v1/payments Idempotency-Key: 9d2f…
{ "id": "9d2f…", "from_address": "asha@sbi", "from_name": "Asha Rao", "to_address": "maya@bofa",
"send": { "value": "248.00", "currency": "INR" }, "receive": { "value": "20.00", "currency": "USD" },
"rate": "12.40", "note": null, "collect_request_id": null }
The US switch checks: maya@bofa is at a US bank; asha@sbi routes to the Indian switch, the caller; INR then USD, rate 12.40; 24800 ÷ 12.40 = 2000. It records 9d2f… as inbound, credits BofA USD 20.00 (with fx and from_country: "IN"), moves to credited, then completed, and books:
| US switch | USD |
|---|---|
bank:bofa | +20.00 |
link:IN | −20.00 |
It answers 200 {"id": "9d2f…", "status": "completed", "state": "completed", "direction": "inbound", "amount": {"value": "248.00", "currency": "INR"}, "receive": {"value": "20.00", "currency": "USD"}, "fee": null, "rate": "12.40", "to_name": "Maya Brooks", …}.
The Indian switch moves its record to credited, then completed, books its side and answers SBI completed:
| Indian switch | INR | Kind |
|---|---|---|
bank:sbi | −248.00 | principal |
link:US | +248.00 | principal |
bank:sbi | −20.00 | fee |
fees:IN | +20.00 | fee |
3. Settlement. The Indian switch’s next cycle shows link:US +248.00 INR, switch_owes_peer, worth USD 20.00. The US switch’s shows link:IN −20.00 USD, peer_owes_switch, worth INR −248.00. Each cycle balances in its own currency.
If BofA had not answered, the US switch would have answered pending, both records would stay received, and SBI’s repeat with the same key would drive both forward and book each side once.
16. Security considerations
- A peer can only speak for its own country. The receiving switch checks the payer’s address routes to the calling switch (LINK-8.6, LINK-10.2), and that a relayed app is registered with the calling switch (LINK-11.5). A compromised peer can still move money from its own country’s addresses: the link trusts each NPC for its own country, as banks trust their own switch.
- Amounts are checked on both sides. The receiving switch recomputes the conversion with its own rate (LINK-8.7, LINK-8.8), so a peer cannot inflate the receive amount.
- Replay. A signature is good for 120 seconds and carries no
jti(OCI-PAY-2 §4). State-changing link calls are protected by idempotency keys and by the payment id (LINK-8.12, LINK-8.13). A replayed quote or lookup does no harm but costs the peer’s banks a call. - Ambiguity is never a failure. Treating “I already have this” answers as unknown (LINK-13.3) stops a switch from telling a payer the money is back while the payee has it.
- No silent recovery. With no timer (LINK-13.5), a payment the payer’s side never drives again stays pending at both switches. Operators need to watch for pending payments.
- Relay and to-provider widen what the link carries. Every relayed call is checked as if the app had made it directly (LINK-11.7). The forward to a provider is limited to
/switch/v1/*paths and to apps registered with the forwarding switch (LINK-12.2, LINK-12.3). An answer passed back unchanged (LINK-11.4, LINK-12.5) can carry whatever the other side wrote, so a switch does not treat a passed-back error message as its own (LINK-14.2). - Nested calls. Validating an inbound payment can itself cross the link: a payee or payer address issued by an app whose home is the sending country is resolved through
/link/v1/to-providerback to the sending switch. Such a payment needs several link round trips inside one forward, and can time out at the sender. It then becomes unknown and is recovered by a repeat. - Peer URL.
PEER_SWITCH_URLoverrides the registry. A wrong value sends signed payment data to the wrong host. It SHOULD be set only where the registry’sbase_urlcannot be used.
17. Privacy considerations
- A lookup answers only the holder’s name, whether it is verified, the bank’s name and an assurance level (LINK-6.3). It never answers an account number or a provider’s account reference.
- A payment on the link carries the two addresses, the payer’s name, the amounts and an optional note. It never carries the payer’s account, the PIN, the fee or the quote id (LINK-8.2).
- A request for money carries the payee’s name and assurance so the payer can be warned about an unknown payee (OCI-PAY-2). It carries no account data.
- Each switch learns every cross-border payment, lookup and relayed call that touches its country. The home switch of a payment app sees every relayed call that app makes, though it keeps no record (LINK-11.4).
- Logs MUST NOT contain PINs, tokens or account numbers in clear text (CORE-7.3).
- Demonstrations MUST use synthetic people and accounts (CORE-7.4). The names in §15 are synthetic.
18. Conformance
An implementation conforms to OCI-PAY-4 0.1 when both of its switches pass the link tests of the reference implementation, ocipay-api/tests/test_switch.py (cross-border quotes, payments, settlement, requests for money and ambiguity) and ocipay-api/tests/test_providers.py (relay and to-provider).
| Clauses | Checked by ocipay-api tests |
|---|---|
| LINK-3.1, 3.2 | test_unsigned_and_badly_signed_calls_are_refused, test_participants_may_only_use_their_own_endpoints |
| LINK-6.x | test_lookup_local_cross_border_and_unknown |
| LINK-7.1 to 7.16 | test_quote_prices_both_directions_and_adds_the_fee, test_quote_rounds_half_even_in_minor_units, test_quote_errors, test_quote_when_the_peer_is_down_is_503 |
| LINK-7.17, 8.18 | test_peer_bank_rejecting_fails_the_payment_and_frees_the_quote |
| LINK-8.5 to 8.8, 8.13 | test_link_refuses_forged_or_inconsistent_payments |
| LINK-8.11, 8.12, 8.14, 13.5 | test_link_repeat_of_the_same_payment_credits_once, test_peer_timeout_is_pending_and_the_peer_dedups_on_retry, test_pending_cross_border_payment_resolves_through_the_peers_own_retry |
| LINK-9.x | test_in_to_us_payment_converts_and_positions_net_to_zero_after_settlement, test_us_to_in_payment_uses_the_us_fee |
| LINK-10.x | test_cross_border_collect_request_relays_over_the_link_and_is_paid_with_a_quote, test_cross_border_collect_decline_and_cancel_are_relayed_both_ways, test_link_collect_requests_are_checked |
| LINK-11.x | test_an_app_connects_a_bank_in_the_other_country_through_its_home_switch, test_an_app_pays_from_an_account_in_the_other_country_and_the_payment_stays_there, test_what_may_be_relayed, test_a_us_app_is_refused_by_the_indian_switch |
| LINK-12.x | test_the_indian_switch_reaches_a_us_app_only_through_the_us_switch, test_a_request_for_money_reaches_a_us_app_through_its_home_switch, test_the_link_forwards_only_to_an_app_registered_here |
| LINK-13.2 to 13.4 | test_peer_switch_already_has_it_answers_keep_the_payment_pending, test_peer_switch_definite_4xx_still_fails_the_payment |
| LINK-4.x, 5.7, 13.1, 14.x | Not checked by a named test in 0.1. |
The tests do not yet cite LINK clause IDs. They should.
19. Open questions
Places where the code, the drafts (docs/api/oci-9-payments-switch.yaml, oci-9-payments.yaml, schemas/payments-*.json, GAPS.md) and the plans (oci-docs 003, 010) disagree, and what looks like a demonstration shortcut. This text follows the code.
Demonstration shortcuts
- Fixed exchange rate. One configured rate (12.40 INR per USD), the same at both switches and in both directions, with no spread, no rate source, no validity period and no way for the two NPCs to agree a change (LINK-7.1). A real link needs a rate that is published, dated, agreed by both sides and carried with the quote. A change of rate at one switch makes every payment fail with
RATE_MISMATCHuntil the other changes too. - The rate has two decimals on the wire (LINK-7.2), but conversion uses the configured value at full precision. A configured rate with more than two decimals would convert with one value and send another.
- Fixed fees, hard-coded. INR 20.00 and USD 1.62 are constants in code, not configuration (LINK-7.7). GAPS notes that 20.00 INR at 12.40 is 1.61 USD. Plan 003 §11 decided 1.62 is a fixed published figure, which the code follows.
- Two countries only. The code assumes exactly one peer and two currencies: “the other currency” is whichever of INR and USD is not the switch’s own, and the peer is the first foreign switch in the registry (LINK-4.1). Routing a payment sends it to that peer without checking the peer’s country is the bank’s (LINK-4.4); relay and to-provider do check (LINK-4.6). A third country breaks all of this.
- Real country codes. The code uses
INandUS, with INR and USD. CORE-3.2 requires test and fictional countries to useXAtoXZ. Plan 003 and the drafts use Tavora (XT, TVD) and Corvane (XC, CVK). Decide which the specs show. - Any foreign switch may call the link. LINK-3.2 accepts any active foreign switch, not only the configured peer. Harmless with two countries.
- No recovery job. Nothing drives a pending payment on a timer (LINK-13.5). BUILD-NOTES records it as a stub. A credited-but-not-booked payment stays
crediteduntil driven again. - No way to read the peer’s state (LINK-13.6), and no reversal:
reversedis never produced. - Settlement between NPCs is not defined (LINK-9.7). Each switch shows its link net; nothing reconciles the two.
Code against the drafts and plans
- Who holds the quote. The draft
POST /link/v1/quotessends aquote_idchosen by the originating switch, the peer holds the same id for 10 minutes, answers201with a full quote (includingfee), and both switches mark it used. GAPS records that design. In the code, the link quote has noquote_id, the peer keeps nothing and answers200 {send, receive, rate, payee_name}, and only the sending switch holds and uses the quote (LINK-7.9, LINK-7.10). Plan 003 §11 says “the originating switch issuesquote_id, and the link reuses it”: the code does not reuse it on the link at all. - The link payment body. The draft wraps it as
{"payment": {..., "amount", "credit_amount", "fee", "quote_id", "status": "received"}}. The code sends it flat:{id, from_address, from_name, to_address, send, receive, rate, note, collect_request_id}, with no fee and no quote id (LINK-8.2). The draft’s “the receiving switch checks that quote_id is held and not expired” cannot happen. - “The peer converts nothing itself.” The draft says the peer credits
credit_amountas given. Plan 003 §8 says the link “converts at the quoted rate”. In the code the peer recomputes the conversion with its own rate and refuses a mismatch (LINK-8.7, LINK-8.8). - The link payment answer. The draft answers
creditedorfailed. The code answers the wire statuscompleted | pending | failed, plusstate(CONTRACT-CHANGES §2), and the sender counts onlycompletedas credited (LINK-8.17). - The lookup answer. The draft answers
{address, name, bank_name, country, assurance}. The code answers{name, verified, bank_name, assurance}, and the sending switch addsaddress,countryandcross_border(LINK-6.3, LINK-6.5). - Requests for money on the link.
/link/v1/collect-requestsand its status call are in the code (CONTRACT-CHANGES §1, plan 003 §11, GAPS) but not in the switch draft. - Relay and to-provider (plan 010) are in the code and CONTRACT-CHANGES but in no draft.
- Positions. The draft’s position participant is
bank:…orswitch:XX, withunsettled_payments. The code useslink:<CC>andfees:<CC>, one row per movement, and answers{participant, net, direction}pluspeerandequivalenton the link row (LINK-9.3). - Error body and codes. The code answers
{"error": {"code", "message"}}, as the draft’spayments-error.jsondoes. CORE-9.1 requires{"error": "<code>", "error_description": "<text>"}. The code’s codes also differ from the draft’s:SIGNATURE_EXPIRED(draftSIGNATURE_STALE),UNKNOWN_PARTICIPANT(draftPARTICIPANT_UNKNOWN),PEER_UNAVAILABLEwith503(draftUPSTREAM_UNAVAILABLEand502 Upstream),INVALID_AMOUNT(draftAMOUNT_INVALID). - Signature algorithm. The link signs with EdDSA (Ed25519) and no
typ(OCI-PAY-2 §4). CORE-5.1 and CORE-5.4 require ES256 and an explicittyp. GAPS already records this. to-provider“unchanged”. Plan 010 says the app’s answer is passed back unchanged. The code keeps the status and a JSON-object body, but turns any other body into{}, drops the app’s headers, and does not forward the caller’sIdempotency-Keyto the app (LINK-12.5). A404 PROVIDER_NOT_HEREfrom the forwarding switch is indistinguishable, at the caller, from the app’s own 404: both are a definite no.- Relay answer status. A relayed
2xxcomes back as200whatever the peer answered (LINK-11.4). A peer answer that is2xxbut not a JSON object becomes503 PEER_UNAVAILABLE.
Behaviour to decide
PAYMENT_ID_TAKENis unknown. A real id clash (LINK-8.13) leaves the sender’s payment pending for ever, with the payer’s money held. Should the link tell a clash apart from “still running”?- Status changes can split. The sending switch commits a request’s new status before the link call (LINK-10.15). If the peer refuses (for example
409 REQUEST_BEING_PAID), the two copies disagree, and nothing reconciles them. payee_countryis taken as sent on an inbound request for money, and itsnotehas no length limit there (the bank-facing call limits it to 140).- A failed payment frees its quote (LINK-7.17). That matches the tests, but means one quote can start several payments in turn. Confirm it is intended.
- Rounding across the link. The sending switch books the link at the send amount, the receiving one at the receive amount. On amounts whose conversion is not exact, the two link nets differ by up to one minor unit per payment (BUILD-NOTES). Reported, not corrected.
- Timeouts. One forward can need several nested link calls (§16), each with its own 7-second limit, inside the sender’s 7 seconds. Should the receiving switch answer
pendingearly instead?
Changes
| Version | Date | What changed |
|---|---|---|
| 0.1.0 | 2026-11-28 | First version, extracted from the reference implementation. Numbered OCI-PAY-4 in the payments family (first drafted as OCI-15). Message tables for each call. |