### Create Multicurrency Wallet Request Examples Source: https://chimoney.readme.io/reference/multicurrency-wallets Examples of how to create a new multicurrency wallet using the Chimoney API. These examples demonstrate POST requests with JSON payloads and include headers for authentication and content type. ```Shell curl --request POST \ --url https://api.chimoney.io/v0.2.4/multicurrency-wallets/create \ --header 'accept: application/json' \ --header 'content-type: application/json' ``` -------------------------------- ### Payment Initiation Request Example (JSON) Source: https://chimoney.readme.io/reference/post_v0-2-4-payment-initiate An example JSON payload for initiating a payment. It includes details such as the amount, currency, payer's email, and preferred payment method. The payment method object specifies the type (e.g., 'card') and region. ```json { "valueInUSD": 10, "payerEmail": "devs@chimoney.io", "redirect_url": "https://test.com", "subAccount": "jnirjmt0405jmd", "currency": "CAD", "amount": 10, "paymentMethod": { "type": "card", "cardRegion": "Americas/Canada" } } ``` -------------------------------- ### Get Agent API Key Info (OpenAPI) Source: https://chimoney.readme.io/reference/get_v0-2-4-agents-api-key This snippet defines the OpenAPI specification for retrieving agent API key information. It specifies the endpoint, HTTP method (GET), parameters (agentId, subAccount), and expected responses, including success and error codes. Authentication is handled via an API key in the header. ```json { "openapi": "3.0.0", "info": { "title": "Chimoney API Docs", "version": "0.2.4", "description": "This is the latest version of the Chimoney API. For deprecated version routes, please refer to /v0.2/api-docs." }, "security": [ { "apiKeyAuth": [] } ], "servers": [ { "url": "https://api.chimoney.io/", "description": "Prod Server" }, { "url": "https://api-v2-sandbox.chimoney.io", "description": "Sandbox API v2 (v0.2.4)" } ], "paths": { "/v0.2.4/agents/api-key": { "get": { "summary": "Get agent API key info", "description": "Retrieves the current API key information for an agent (without exposing the secret)", "tags": [ "Agents" ], "security": [ { "apiKeyAuth": [] } ], "parameters": [ { "in": "query", "name": "agentId", "required": true, "schema": { "type": "string" }, "description": "Agent UID" }, { "in": "query", "name": "subAccount", "required": false, "schema": { "type": "string" }, "description": "Sub-account identifier" } ], "responses": { "200": { "description": "API key information", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string", "example": "success" }, "data": { "type": "object", "nullable": true, "properties": { "id": { "type": "string" }, "key": { "type": "string" }, "appName": { "type": "string" }, "webhookUrl": { "type": "string", "nullable": true, "description": "Webhook URL for agent events" }, "createdAt": { "type": "string" }, "revoked": { "type": "boolean" }, "revokedAt": { "type": "string", "nullable": true } } }, "message": { "type": "string" } } } } } }, "400": { "$ref": "#/components/responses/ValidationError" }, "401": { "$ref": "#/components/responses/Unauthorized" }, "404": { "$ref": "#/components/responses/NotFound" }, "500": { "$ref": "#/components/responses/ServerError" } } } } }, "components": { "securitySchemes": { "apiKeyAuth": { "type": "apiKey", "in": "header", "name": "X-API-KEY" } }, "responses": { "Unauthorized": { "description": "Access to this resource is not available for unauthenticated users.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Unauthorized" } } } }, "ServerError": { "description": "Indicates an internal server error.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ServerError" } } } }, "ValidationError": { "description": "Validation error in the request.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ValidationError" } } } }, "NotFound": { "description": "The requested resource was not found.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NotFound" } } } } }, "schemas": { "Unauthorized": { "type": "object", "properties": { "status": { "type": "string", "description": "Status of the response.", "example": "error" }, "error": { "type": "string" } } }, "ServerError": { "type": "object", "properties": { "status": { "type": "string", "description": "Status of the response.", "example": "error" }, "error": { "type": "string" } } }, "ValidationError": { "type": "object", "properties": { "status": { "type": "string", "description": "Status of the response.", "example": "error" }, "error": { "type": "string" } } }, "NotFound": { "type": "object", "properties": { "status": { "type": "string", "description": "Status of the response.", "example": "error" }, "error": { "type": "string" } } } } } } ``` -------------------------------- ### Get Transaction Details by IssueID (Python) Source: https://chimoney.readme.io/reference/account Python example for calling the Chimoney API to retrieve transaction details using a specific issueID. This typically uses the 'requests' library. ```python # Python example (conceptual) # Requires 'requests' library import requests def get_transaction_details(issue_id): url = "https://api.chimoney.io/v0.2.4/accounts/issue-id-transactions" headers = { "accept": "application/json", "content-type": "application/json" } payload = { "issueID": issue_id # "subAccount": "your_subaccount_if_any" } try: response = requests.post(url, headers=headers, json=payload) response.raise_for_status() # Raise an exception for bad status codes return response.json() except requests.exceptions.RequestException as e: print(f"Error fetching transaction details: {e}") return None # Example usage: # issue_id_to_fetch = "your_issue_id" # transaction_data = get_transaction_details(issue_id_to_fetch) # if transaction_data: # print(transaction_data) # else: # print("Failed to retrieve transaction details.") ``` -------------------------------- ### Get Transaction Details by IssueID (PHP) Source: https://chimoney.readme.io/reference/account PHP example for fetching transaction details by issueID from the Chimoney API. This typically uses cURL functions or a library like Guzzle. ```php $issueID]); // Add 'subAccount' if needed $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if (curl_errno($ch)) { echo 'Curl error: ' . curl_error($ch); curl_close($ch); return null; } curl_close($ch); if ($httpCode >= 200 && $httpCode < 300) { return json_decode($response, true); } else { echo "HTTP Error: " . $httpCode . "\n"; echo "Response: " . $response . "\n"; return null; } } // Example usage: // $issueId = 'your_issue_id'; // $details = getTransactionDetails($issueId); // if ($details) { // print_r($details); // } else { // echo "Failed to retrieve transaction details."; // } ?> ``` -------------------------------- ### POST /v0.2.4/agents/create Source: https://chimoney.readme.io/reference/post_v0-2-4-agents-create Creates a new AI agent account with a multicurrency wallet and payment pointer. ```APIDOC ## POST /v0.2.4/agents/create ### Description Creates an agent sub-account with APort passport, multicurrency wallet, and payment pointer. ### Method POST ### Endpoint /v0.2.4/agents/create ### Parameters #### Request Body - **name** (string) - Required - Agent name - **description** (string) - Optional - Agent description - **email** (string) - Optional - Agent email (auto-generated if not provided) - **subAccount** (string) - Optional - Sub-account identifier - **limits** (object) - Optional - Transaction limits - **USD** (object) - Optional - USD transaction limits - **maxPerTx** (integer) - Optional - Maximum transaction amount in USD - **dailyCap** (integer) - Optional - Daily transaction cap in USD - **CAD** (object) - Optional - CAD transaction limits - **maxPerTx** (integer) - Optional - Maximum transaction amount in CAD - **dailyCap** (integer) - Optional - Daily transaction cap in CAD - **NGN** (object) - Optional - NGN transaction limits - **maxPerTx** (integer) - Optional - Maximum transaction amount in NGN - **dailyCap** (integer) - Optional - Daily transaction cap in NGN - **MXN** (object) - Optional - MXN transaction limits - **maxPerTx** (integer) - Optional - Maximum transaction amount in MXN - **dailyCap** (integer) - Optional - Daily transaction cap in MXN - **refundAmountMaxPerTx** (integer) - Optional - Maximum refund amount per transaction - **refundAmountDailyCap** (integer) - Optional - Daily refund cap - **approvalRequired** (boolean) - Optional - Whether approval is required for transactions - **capabilities** (array) - Optional - Agent capabilities (finance.* or wallet.* only) ### Request Example ```json { "name": "PaymentBot", "description": "AI Agent for processing payments", "email": "agent-123@agents.chimoney.io", "subAccount": "unique-sub-account-id", "limits": { "USD": { "maxPerTx": 10000, "dailyCap": 100000 }, "CAD": { "maxPerTx": 10000, "dailyCap": 100000 }, "NGN": { "maxPerTx": 10000, "dailyCap": 100000 }, "MXN": { "maxPerTx": 10000, "dailyCap": 100000 }, "refundAmountMaxPerTx": 5000, "refundAmountDailyCap": 50000, "approvalRequired": false }, "capabilities": [ "finance.send", "wallet.receive" ] } ``` ### Response #### Success Response (200) - **agentId** (string) - Description - **name** (string) - Description - **email** (string) - Description - **status** (string) - Description - **createdAt** (string) - Description - **updatedAt** (string) - Description - **subAccount** (string) - Description - **paymentPointer** (string) - Description - **walletDetails** (object) - Description - **currency** (string) - Description - **balance** (number) - Description - **id** (string) - Description #### Response Example ```json { "agentId": "agent_abc123", "name": "PaymentBot", "email": "agent-123@agents.chimoney.io", "status": "active", "createdAt": "2023-10-27T10:00:00Z", "updatedAt": "2023-10-27T10:00:00Z", "subAccount": "unique-sub-account-id", "paymentPointer": "$chimoney.io/agent_abc123", "walletDetails": [ { "currency": "USD", "balance": 0.0, "id": "wallet_usd_abc123" }, { "currency": "NGN", "balance": 0.0, "id": "wallet_ngn_abc123" } ] } ``` ``` -------------------------------- ### Initiate Payment Request (Node.js) Source: https://chimoney.readme.io/reference/payments-1 Example of initiating a payment request using Node.js with the 'axios' library. This shows how to construct the request payload and send it to the Chimoney API. ```javascript const axios = require('axios'); const initiatePayment = async () => { try { const response = await axios.post('https://api.chimoney.io/v0.2.4/payment/initiate', { paymentMethod: { type: 'card' } }, { headers: { 'accept': 'application/json', 'content-type': 'application/json' } }); console.log(response.data); } catch (error) { console.error('Error initiating payment:', error); } }; initiatePayment(); ``` -------------------------------- ### Get Transaction Details by IssueID (Ruby) Source: https://chimoney.readme.io/reference/account Ruby example for retrieving transaction details by issueID via the Chimoney API. This would typically involve using the 'net/http' library or a gem like 'httparty'. ```ruby # Ruby example (conceptual) # Requires 'net/http' or 'httparty' require 'net/http' require 'uri' require 'json' def get_transaction_details(issue_id) uri = URI.parse('https://api.chimoney.io/v0.2.4/accounts/issue-id-transactions') http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request['accept'] = 'application/json' request['content-type'] = 'application/json' body = { issueID: issue_id # subAccount: 'your_subaccount_if_any' }.to_json request.body = body response = http.request(request) JSON.parse(response.body) rescue => e puts "Error fetching transaction details: #{e.message}" raise e end # Example usage: # begin # details = get_transaction_details('your_issue_id') # puts details # rescue => e # puts "Failed to get details." # end ``` -------------------------------- ### Initiate Payment Request (Ruby) Source: https://chimoney.readme.io/reference/payments-1 Example of initiating a payment request using Ruby with the 'net/http' library. This demonstrates constructing and sending a POST request with a JSON payload to the Chimoney API. ```ruby require 'net/http' require 'uri' require 'json' uri = URI.parse("https://api.chimoney.io/v0.2.4/payment/initiate") request = Net::HTTP::Post.new(uri) request["content-type"] = "application/json" request["accept"] = "application/json" request.body = JSON.dump({ "paymentMethod": { "type": "card" } }) response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(request) end puts JSON.parse(response.body) ``` -------------------------------- ### Get Transaction Details by IssueID (cURL) Source: https://chimoney.readme.io/reference/account Example using cURL to make a POST request to the Chimoney API to retrieve transaction details associated with a given issueID. Requires 'accept' and 'content-type' headers. ```shell curl --request POST \ --url https://api.chimoney.io/v0.2.4/accounts/issue-id-transactions \ --header 'accept: application/json' \ --header 'content-type: application/json' ``` -------------------------------- ### Create Multicurrency Wallet with Ruby Source: https://chimoney.readme.io/reference/multicurrency-wallets Example of creating a new multicurrency wallet using Ruby and the 'net/http' library. This snippet demonstrates how to construct and send a POST request to the Chimoney API. ```ruby require 'net/http' require 'uri' require 'json' def create_wallet(name, email, first_name, last_name, phone_number, meta) uri = URI.parse('https://api.chimoney.io/v0.2.4/multicurrency-wallets/create') http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request['accept'] = 'application/json' request['content-type'] = 'application/json' request.body = { name: name, email: email, firstName: first_name, lastName: last_name, phoneNumber: phone_number, meta: meta }.to_json response = http.request(request) JSON.parse(response.body) end # Example usage: # puts create_wallet('Jane Doe', 'jane.doe@example.com', 'Jane', 'Doe', '+1987654321', { source: 'web' }) ``` -------------------------------- ### Get Transaction Details by IssueID (Node.js) Source: https://chimoney.readme.io/reference/account Node.js example demonstrating how to fetch transaction details by issueID using the Chimoney API. This code snippet would typically use a library like 'axios' or the built-in 'https' module. ```javascript // Node.js example (conceptual) // Requires 'axios' or similar library const axios = require('axios'); async function getTransactionDetails(issueID) { const url = 'https://api.chimoney.io/v0.2.4/accounts/issue-id-transactions'; const headers = { 'accept': 'application/json', 'content-type': 'application/json' }; const data = { issueID: issueID // subAccount: 'your_subaccount_if_any' }; try { const response = await axios.post(url, data, { headers: headers }); return response.data; } catch (error) { console.error('Error fetching transaction details:', error.response ? error.response.data : error.message); throw error; } } // Example usage: // getTransactionDetails('your_issue_id').then(data => console.log(data)).catch(err => console.error(err)); ``` -------------------------------- ### Initiate Payment Request (Python) Source: https://chimoney.readme.io/reference/payments-1 Example of initiating a payment request using Python with the 'requests' library. This illustrates how to send a POST request with a JSON body to the Chimoney API. ```python import requests url = "https://api.chimoney.io/v0.2.4/payment/initiate" headers = { "accept": "application/json", "content-type": "application/json" } data = { "paymentMethod": { "type": "card" } } response = requests.post(url, json=data, headers=headers) print(response.json()) ``` -------------------------------- ### Get Beneficiaries - Python Request Source: https://chimoney.readme.io/reference/beneficiary This Python snippet shows how to get beneficiaries using the 'requests' library. It sends a GET request to the API endpoint with the appropriate 'accept' header. ```python import requests url = 'https://api.chimoney.io/v0.2.4/beneficiary' headers = { 'accept': 'application/json' } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Get Beneficiaries - Ruby Request Source: https://chimoney.readme.io/reference/beneficiary This Ruby snippet illustrates how to retrieve beneficiaries using the 'net/http' library. It constructs a GET request to the Chimoney API endpoint. ```ruby require 'net/http' require 'uri' uri = URI.parse('https://api.chimoney.io/v0.2.4/beneficiary') request = Net::HTTP::Get.new(uri) request['accept'] = 'application/json' response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(request) end puts response.body ``` -------------------------------- ### POST /api/v1/agent/create Source: https://chimoney.readme.io/reference/post_v0-2-4-agents-create This endpoint allows you to create a new AI agent sub-account. Upon successful creation, the agent will be provisioned with an APort passport, a multicurrency wallet, and a payment pointer. ```APIDOC ## POST /api/v1/agent/create ### Description Creates an agent sub-account with APort passport, multicurrency wallet, and payment pointer. ### Method POST ### Endpoint /api/v1/agent/create ### Parameters #### Query Parameters - **email** (string) - Required - The email address for the agent account. - **name** (string) - Required - The name of the agent. ### Request Example ```json { "email": "agent@example.com", "name": "AI Agent Name" } ``` ### Response #### Success Response (201) - **agent_id** (string) - The unique identifier for the created agent. - **passport_id** (string) - The identifier for the agent's APort passport. - **wallet_id** (string) - The identifier for the agent's multicurrency wallet. - **payment_pointer** (string) - The payment pointer associated with the agent's wallet. #### Response Example ```json { "agent_id": "ag_12345abcde", "passport_id": "pa_67890fghij", "wallet_id": "wa_11223klmno", "payment_pointer": "$ilp.uphold.com/v1/agent_wallet_address" } ``` ``` -------------------------------- ### Get Beneficiaries - PHP Request Source: https://chimoney.readme.io/reference/beneficiary This PHP snippet demonstrates fetching beneficiaries using cURL. It sets up a GET request to the Chimoney API endpoint with the 'accept' header. ```php ``` -------------------------------- ### Initiate Payment Request (cURL) Source: https://chimoney.readme.io/reference/payments-1 Example of initiating a payment request using cURL. This demonstrates the POST request to the Chimoney API endpoint with JSON payload. ```shell curl --request POST \ --url https://api.chimoney.io/v0.2.4/payment/initiate \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data '{ "paymentMethod": { "type": "card" } }' ``` -------------------------------- ### Get Beneficiaries - cURL Request Source: https://chimoney.readme.io/reference/beneficiary This snippet demonstrates how to make a GET request to the Chimoney API to retrieve a list of beneficiaries. It requires an 'accept' header set to 'application/json'. ```shell curl --request GET \ --url https://api.chimoney.io/v0.2.4/beneficiary \ --header 'accept: application/json' ``` -------------------------------- ### Create Multicurrency Wallet with Python Source: https://chimoney.readme.io/reference/multicurrency-wallets Example of creating a new multicurrency wallet using Python and the 'requests' library. This snippet demonstrates how to make a POST request to the Chimoney API with a JSON payload. ```python import requests def create_wallet(name, email, first_name, last_name, phone_number, meta): url = 'https://api.chimoney.io/v0.2.4/multicurrency-wallets/create' headers = { 'accept': 'application/json', 'content-type': 'application/json' } payload = { 'name': name, 'email': email, 'firstName': first_name, 'lastName': last_name, 'phoneNumber': phone_number, 'meta': meta } try: response = requests.post(url, headers=headers, json=payload) response.raise_for_status() # Raise an exception for bad status codes return response.json() except requests.exceptions.RequestException as e: print(f'Error creating wallet: {e}') return None # Example usage: # wallet_info = create_wallet('Alice Smith', 'alice.smith@example.com', 'Alice', 'Smith', '+1555666777', {'source': 'api'}) # if wallet_info: # print(wallet_info) ``` -------------------------------- ### Get Beneficiaries - Node.js Request Source: https://chimoney.readme.io/reference/beneficiary This Node.js snippet shows how to fetch beneficiaries using the 'node-fetch' library. It makes a GET request to the specified API endpoint with the necessary headers. ```javascript const fetch = require('node-fetch'); const url = 'https://api.chimoney.io/v0.2.4/beneficiary'; fetch(url, { method: 'GET', headers: { 'accept': 'application/json' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Initiate Payment Request (PHP) Source: https://chimoney.readme.io/reference/payments-1 Example of initiating a payment request using PHP with cURL. This shows how to set up a cURL request to send a POST request with a JSON body to the Chimoney API. ```php [ 'type' => 'card' ] ]; $headers = [ 'Content-Type: application/json', 'Accept: application/json' ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } else { echo $response; } c_l_close($ch); ?> ``` -------------------------------- ### Create Sub-Account API Request (Node.js) Source: https://chimoney.readme.io/reference/subaccount Node.js example using `axios` to create a new sub-account. It shows how to send a POST request with the necessary headers and body parameters to the Chimoney API. ```javascript const axios = require('axios'); const createSubAccount = async (name, email, firstName, lastName, phoneNumber, meta) => { try { const response = await axios.post('https://api.chimoney.io/v0.2.4/sub-account/create', { name: name, email: email, firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, meta: meta }, { headers: { 'accept': 'application/json', 'content-type': 'application/json' } }); return response.data; } catch (error) { console.error('Error creating sub-account:', error.response ? error.response.data : error.message); throw error; } }; // Example usage: // createSubAccount('John Doe', 'john.doe@example.com', 'John', 'Doe', '+1234567890', { key: 'value' }) // .then(data => console.log(data)) // .catch(err => console.error(err)); ``` -------------------------------- ### GET /beneficiary Source: https://chimoney.readme.io/reference/beneficiary Retrieves a list of all beneficiaries associated with the authenticated user. Supports optional subaccount filtering. ```APIDOC ## GET /beneficiary ### Description Retrieves a list of all beneficiaries associated with the authenticated user. This endpoint can optionally filter beneficiaries by a subaccount ID. ### Method GET ### Endpoint https://api.chimoney.io/v0.2.4/beneficiary ### Parameters #### Query Parameters - **subAccount** (string) - Optional - The ID of the subaccount to filter beneficiaries by. ### Request Example ```json { "example": "curl --request GET \ --url https://api.chimoney.io/v0.2.4/beneficiary \ --header 'accept: application/json'" } ``` ### Response #### Success Response (200) - **status** (string) - The status of the response. - **message** (string) - A message describing the result of the request. - **data** (array of objects) - A list of beneficiary objects. - **id** (string) - The unique identifier for the beneficiary. - **accountNumber** (string) - The bank account number of the beneficiary. - **bankCurrency** (object) - An object containing information about the bank and currency. - **channel** (string) - The channel used for the transaction. - **createdDate** (date-time) - The date and time when the beneficiary was created. #### Error Response (401) - **status** (string) - The status of the response, indicating an error. - **error** (string) - A message detailing the unauthorized access error. #### Error Response (500) - **status** (string) - The status of the response, indicating a server error. - **type** (string) - The type of server error. - **code** (string) - A specific error code for the server issue. - **message** (string) - A detailed message explaining the server error. #### Response Example (200) ```json { "status": "success", "message": "Beneficiaries retrieved successfully", "data": [ { "id": "beneficiary_id_123", "accountNumber": "1234567890", "bankCurrency": { "channel": "bank_transfer" }, "createdDate": "2023-10-27T10:00:00Z" } ] } ``` #### Response Example (401) ```json { "status": "error", "error": "Unauthorized access" } ``` #### Response Example (500) ```json { "status": "error", "type": "server_error", "code": "ERR500", "message": "An internal server error occurred" } ``` ``` -------------------------------- ### Create Sub-Account API Request (Python) Source: https://chimoney.readme.io/reference/subaccount Python example using the `requests` library to create a new sub-account. It demonstrates sending a POST request with a JSON payload to the Chimoney API. ```python import requests import json url = "https://api.chimoney.io/v0.2.4/sub-account/create" payload = { "name": "Alice Smith", "email": "alice.smith@example.com", "firstName": "Alice", "lastName": "Smith", "phoneNumber": "+15551234567", "meta": {"user_id": 123} } headers = { "accept": "application/json", "content-type": "application/json" } try: response = requests.post(url, json=payload, headers=headers) response.raise_for_status() # Raise an exception for bad status codes print(json.dumps(response.json(), indent=2)) except requests.exceptions.RequestException as e: print(f"Error creating sub-account: {e}") if hasattr(e, 'response') and e.response is not None: print(f"Response status: {e.response.status_code}") print(f"Response body: {e.response.text}") ``` -------------------------------- ### Get Supported Airtime Countries (PHP) Source: https://chimoney.readme.io/reference/info This PHP code snippet shows how to make a GET request to the Chimoney API to retrieve a list of supported airtime countries. It uses cURL to send the request and processes the JSON response. ```php ``` -------------------------------- ### POST /agents/create Source: https://chimoney.readme.io/reference/agents Creates an agent sub-account with APort passport, multicurrency wallet, and payment pointer. ```APIDOC ## POST /agents/create ### Description Creates an agent sub-account with APort passport, multicurrency wallet, and payment pointer. ### Method POST ### Endpoint https://api.chimoney.io/v0.2.4/agents/create ### Parameters #### Request Body - **name** (string) - Required - Agent name - **description** (string) - Optional - Agent description - **email** (string) - Optional - Agent email (auto-generated if not provided) - **subAccount** (string) - Optional - Sub-account identifier - **limits** (object) - Optional - Transaction limits - **capabilities** (array) - Optional - Agent capabilities (finance._or wallet._ only) - **regions** (array of strings) - Optional - Allowed regions (ISO country codes) - **meta** (object) - Optional - Additional metadata - **interledgerWalletAddress** (string) - Optional - Custom Interledger wallet address/payment pointer - **initialFunding** (number | string | object) - Optional - Initial funding to transfer from parent wallet ### Request Example ```json { "name": "Agent Name", "description": "Agent Description", "email": "agent@example.com", "subAccount": "sub_12345", "limits": {}, "capabilities": ["finance._"], "regions": ["NG"], "meta": {}, "interledgerWalletAddress": "custom_payment_pointer", "initialFunding": 100 } ``` ### Response #### Success Response (200) - **status** (string) - Agent creation status. - **data** (object) - Contains agent details. - **uid** (string) - Unique identifier for the agent. - **name** (string) - Name of the agent. - **email** (string) - Email of the agent. - **paymentPointer** (string) - The agent's payment pointer. - **aportPassportId** (string) - APort passport ID. - **aportDID** (string) - APort DID. - **assuranceLevel** (string) - Assurance level of the agent. #### Response Example ```json { "status": "success", "data": { "uid": "agent_uid_123", "name": "Agent Name", "email": "agent@example.com", "paymentPointer": "$rzr.link/chimoney", "aportPassportId": "passport_id_abc", "aportDID": "did:aport:12345", "assuranceLevel": "high" } } ``` #### Error Responses - **400 Bad Request**: Validation error in the request. - **status** (string) - Status of the validation error. - **type** (string) - Type of validation error. - **code** (string) - Error code indicating validation issue. - **message** (string) - Detailed validation error message. - **401 Unauthorized**: Access to this resource is not available for unauthenticated users. - **status** (string) - Status of the response. - **error** (string) - Error message indicating unauthorized access. - **500 Internal Server Error**: Indicates an internal server error. - **status** (string) - Status of the error. - **type** (string) - Type of server error. - **code** (string) - Specific error code for server issues. - **message** (string) - Detailed message explaining the issue. ``` -------------------------------- ### Get Supported Airtime Countries (Ruby) Source: https://chimoney.readme.io/reference/info This Ruby code snippet illustrates how to fetch supported airtime countries by making an HTTP GET request to the Chimoney API. It uses the built-in 'net/http' library and handles the JSON response. ```ruby require 'net/http' require 'uri' require 'json' uri = URI.parse("https://api.chimoney.io/v0.2.4/info/airtime-countries") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Get.new(uri.request_uri) request["accept"] = "application/json" begin response = http.request(request) if response.code == '200' data = JSON.parse(response.body) puts data else puts "Error: #{response.code} - #{response.message}" end rescue StandardError => e puts "An error occurred: #{e.message}" end ``` -------------------------------- ### Initiate Airtime Payout (Node.js) Source: https://chimoney.readme.io/reference/payouts This Node.js example shows how to make a POST request to the Chimoney API to initiate an airtime payout. It utilizes the 'axios' library for HTTP requests and includes the required headers and a sample request body. ```javascript const axios = require('axios'); const options = { method: 'POST', url: 'https://api.chimoney.io/v0.2.4/payouts/airtime', headers: { accept: 'application/json', 'content-type': 'application/json' }, data: { subAccount: 'YOUR_SUB_ACCOUNT_ID', turnOffNotification: false, airtimes: [ { phoneNumber: '2348012345678', amount: 1000, currencyCode: 'NGN', callerNumber: '2348012345678' } ] } }; axios.request(options).then(function (response) { console.log(response.data); }).catch(function (error) { console.error(error); }); ```