Welcome to the rail Developer Guide!
rail API Specification (1.1.2)
https://docs.rail.io/_mock/api-docs/openapi/rail-spec/
https://sandbox.layer2financial.com/api/
https://platform.layer2financial.com/api/
Optional Unique ID per request, useful for fault resolution/diagnosis and audit.
Unique ID used to safely retry an operation. See idempotency section for more details.
Client signature to validate the provence of the API request. See signing section for more details.
Default value: 0.01
The maximum slippage rail will consider when accepting this order. Defined in bps and represented as a percentage. So 10bps would be presented as 0.001. Must be greater than or equal to 0.
We calculate slippage based on the quote you are accepting. While the slippage may not always be used, it is there to ensure a better completion/fill rate with our market makers.
Where the quote cannot be fulfilled within the slippage tolerance, the exchange response status will be CANCELLED.
- Mock server
https://docs.rail.io/_mock/api-docs/openapi/rail-spec/v1/exchanges/{exchange_id}/accept
- Sandbox - Stable API Instance
https://sandbox.layer2financial.com/api/v1/exchanges/{exchange_id}/accept
- Production - Stable API Instance
https://platform.layer2financial.com/api/v1/exchanges/{exchange_id}/accept
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
'https://docs.rail.io/_mock/api-docs/openapi/rail-spec/v1/exchanges/{exchange_id}/accept' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
-H 'Content-Type: application/json' \
-H 'x-l2f-idempotency-id: string' \
-H 'x-l2f-request-id: string' \
-H 'x-signature: string' \
-H 'x-timestamp: string' \
-d '{
"maximum_slippage": 0
}'Success
Status of the Exchange. Cannot be modified directly by the client.
REQUESTED- Exchange request is created and has passed validation. It must be accepted at which point it will be executed.ACCEPTED- Exchange request has been accepted and is waiting execution. At this point it cannot be cancelled.EXPIRED- Occurs when an exchange request was not accepted within a reasonable time frame. The exchange cannot be replayed from this state.CANCELLED- Exchange request was cancelled. Only available prior to acceptance. The exchange request cannot be replayed from this state.EXECUTED- Exchange request has been executed, it is completed with all ledger entries performed.REJECTED- Exchange request was rejected and cannot be executed.
The action defines which side of the exchange to fix.
FIX_DESTINATION- This fixes the amount to credit to theDESTINATIONaccount, therefore the quote provided is for how much to deduct from theSOURCEaccount. Think of this as 'buying' the destination amount.FIX_SOURCE- This fixes the amount you want to debit from theSOURCEaccount, therefore the quote provided is for how much would be credited to theDESTINATIONaccount. Think of this as 'selling' the source amount.
Details of transaction to be performed on the source account on acceptance
Asset type IDs follow a simple structure as follows: {$BLOCKCHAIN}_{$NETWORK}_{$CURRENCY_CODE} Simple asset type to test with include.
ETHEREUM_SEPOLIA_ETHETHEREUM_SEPOLIA_USDCSOLANA_DEVNET_SOLBITCOIN_TESTNET_BTCFIAT_TESTNET_USDFIAT_TESTNET_USDFIAT_MAINNET_USDFIAT_TESTNET_EUR
Details of transaction to be performed on the destination account on acceptance
Asset type IDs follow a simple structure as follows: {$BLOCKCHAIN}_{$NETWORK}_{$CURRENCY_CODE} Simple asset type to test with include
ETHEREUM_SEPOLIA_ETHETHEREUM_SEPOLIA_USDCSOLANA_DEVNET_SOLBITCOIN_TESTNET_BTCFIAT_TESTNET_USDFIAT_TESTNET_USDFIAT_MAINNET_USDFIAT_TESTNET_EUR
{ "data": { "id": "string", "status": "REQUESTED", "created_timestamp": "2019-08-24T14:15:22Z", "exchange_type": "MARKET", "action": "FIX_DESTINATION", "source_details": { … }, "destination_details": { … } } }
Request
When requesting a market exchange, the quote received is indicative ONLY. This represents an approximate rate from our liquidity providers. On accepting a market exchange the trade is performed at the current market rate which will be different to the quote presented to you.
Note: Not all custodians support all order types. Where the order type is not possible (Quote/Market/Fix Destination/ Fix Source) an error will be returned.
Optional Unique ID per request, useful for fault resolution/diagnosis and audit.
Unique ID used to safely retry an operation. See idempotency section for more details.
Type of exchange being performed.
FIX_DESTINATION- This fixes the amount to credit to theDESTINATIONaccount, therefore the quote provided is for how much to deduct from theSOURCEaccount. Think of this as 'buying' the destination amount.FIX_SOURCE- This fixes the amount you want to debit from theSOURCEaccount, therefore the quote provided is for how much would be credited to theDESTINATIONaccount. Think of this as 'selling' the source amount.
- Mock server
https://docs.rail.io/_mock/api-docs/openapi/rail-spec/v1/exchanges/market
- Sandbox - Stable API Instance
https://sandbox.layer2financial.com/api/v1/exchanges/market
- Production - Stable API Instance
https://platform.layer2financial.com/api/v1/exchanges/market
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
https://docs.rail.io/_mock/api-docs/openapi/rail-spec/v1/exchanges/market \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
-H 'Content-Type: application/json' \
-H 'x-l2f-idempotency-id: string' \
-H 'x-l2f-request-id: string' \
-d '{
"source_account_id": "string",
"destination_account_id": "string",
"amount": 0,
"action": "FIX_DESTINATION",
"description": "string"
}'Success
Status of the Exchange. Cannot be modified directly by the client.
REQUESTED- Exchange request is created and has passed validation. It must be accepted at which point it will be executed.ACCEPTED- Exchange request has been accepted and is waiting execution. At this point it cannot be cancelled.EXPIRED- Occurs when an exchange request was not accepted within a reasonable time frame. The exchange cannot be replayed from this state.CANCELLED- Exchange request was cancelled. Only available prior to acceptance. The exchange request cannot be replayed from this state.EXECUTED- Exchange request has been executed, it is completed with all ledger entries performed.REJECTED- Exchange request was rejected and cannot be executed.
The action defines which side of the exchange to fix.
FIX_DESTINATION- This fixes the amount to credit to theDESTINATIONaccount, therefore the quote provided is for how much to deduct from theSOURCEaccount. Think of this as 'buying' the destination amount.FIX_SOURCE- This fixes the amount you want to debit from theSOURCEaccount, therefore the quote provided is for how much would be credited to theDESTINATIONaccount. Think of this as 'selling' the source amount.
Details of transaction to be performed on the source account on acceptance
Asset type IDs follow a simple structure as follows: {$BLOCKCHAIN}_{$NETWORK}_{$CURRENCY_CODE} Simple asset type to test with include.
ETHEREUM_SEPOLIA_ETHETHEREUM_SEPOLIA_USDCSOLANA_DEVNET_SOLBITCOIN_TESTNET_BTCFIAT_TESTNET_USDFIAT_TESTNET_USDFIAT_MAINNET_USDFIAT_TESTNET_EUR
Details of transaction to be performed on the destination account on acceptance
Asset type IDs follow a simple structure as follows: {$BLOCKCHAIN}_{$NETWORK}_{$CURRENCY_CODE} Simple asset type to test with include
ETHEREUM_SEPOLIA_ETHETHEREUM_SEPOLIA_USDCSOLANA_DEVNET_SOLBITCOIN_TESTNET_BTCFIAT_TESTNET_USDFIAT_TESTNET_USDFIAT_MAINNET_USDFIAT_TESTNET_EUR
{ "data": { "id": "string", "status": "REQUESTED", "created_timestamp": "2019-08-24T14:15:22Z", "exchange_type": "MARKET", "action": "FIX_DESTINATION", "source_details": { … }, "destination_details": { … } } }
- Mock server
https://docs.rail.io/_mock/api-docs/openapi/rail-spec/v1/exchanges/{exchange_id}
- Sandbox - Stable API Instance
https://sandbox.layer2financial.com/api/v1/exchanges/{exchange_id}
- Production - Stable API Instance
https://platform.layer2financial.com/api/v1/exchanges/{exchange_id}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
'https://docs.rail.io/_mock/api-docs/openapi/rail-spec/v1/exchanges/{exchange_id}' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
-H 'x-l2f-request-id: string'Success
Status of the Exchange. Cannot be modified directly by the client.
REQUESTED- Exchange request is created and has passed validation. It must be accepted at which point it will be executed.ACCEPTED- Exchange request has been accepted and is waiting execution. At this point it cannot be cancelled.EXPIRED- Occurs when an exchange request was not accepted within a reasonable time frame. The exchange cannot be replayed from this state.CANCELLED- Exchange request was cancelled. Only available prior to acceptance. The exchange request cannot be replayed from this state.EXECUTED- Exchange request has been executed, it is completed with all ledger entries performed.REJECTED- Exchange request was rejected and cannot be executed.
The action defines which side of the exchange to fix.
FIX_DESTINATION- This fixes the amount to credit to theDESTINATIONaccount, therefore the quote provided is for how much to deduct from theSOURCEaccount. Think of this as 'buying' the destination amount.FIX_SOURCE- This fixes the amount you want to debit from theSOURCEaccount, therefore the quote provided is for how much would be credited to theDESTINATIONaccount. Think of this as 'selling' the source amount.
Details of transaction to be performed on the source account on acceptance
Asset type IDs follow a simple structure as follows: {$BLOCKCHAIN}_{$NETWORK}_{$CURRENCY_CODE} Simple asset type to test with include.
ETHEREUM_SEPOLIA_ETHETHEREUM_SEPOLIA_USDCSOLANA_DEVNET_SOLBITCOIN_TESTNET_BTCFIAT_TESTNET_USDFIAT_TESTNET_USDFIAT_MAINNET_USDFIAT_TESTNET_EUR
Details of transaction to be performed on the destination account on acceptance
Asset type IDs follow a simple structure as follows: {$BLOCKCHAIN}_{$NETWORK}_{$CURRENCY_CODE} Simple asset type to test with include
ETHEREUM_SEPOLIA_ETHETHEREUM_SEPOLIA_USDCSOLANA_DEVNET_SOLBITCOIN_TESTNET_BTCFIAT_TESTNET_USDFIAT_TESTNET_USDFIAT_MAINNET_USDFIAT_TESTNET_EUR
{ "data": { "id": "string", "status": "REQUESTED", "created_timestamp": "2019-08-24T14:15:22Z", "exchange_type": "MARKET", "action": "FIX_DESTINATION", "source_details": { … }, "destination_details": { … } } }