> ## Documentation Index
> Fetch the complete documentation index at: https://docs.swervpay.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Create FX

> Create exchange

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.swervpay.co/api/v1/fx/exchange \
    -H "Authorization: Bearer <TOKEN>" \
    -H "Content-Type: application/json" \
    -d '{
      "from": "NGN",
      "to": "USD",
      "amount": 1
    }'
  ```

  ```javascript Node.js theme={null}
  import { SwervpayClient } from '@swervpaydev/sdk';

  const config = {
      secretKey: "<SECRET_KEY>",
      businessId: "<BUSINESS_ID>"
  }

  const swervpay = new SwervpayClient(config);

  await swervpay.fx.exchange({
      amount: 100,
      currency: 'NGN',
      to: 'USD'
  })
  ```

  ```php PHP theme={null}
  use Swervpaydev\SDK\Swervpay;

  $config = [
  	'business_id' => '<BUSINESS_ID>',
  	'secret_key' => '<SECRET_KEY>'
  ];

  $client = new Swervpay($config);

  $client->fx()->exchange([
      'amount' => 100,
      'currency' => 'NGN',
      'to' => 'USD'
  ]);
  ```

  ```go Go theme={null}
  package main

  import (
  	"context"
  	"fmt"
  	"github.com/swerv-ltd/swervpay-go"
  	"log"
  )

  func main() {
  	ctx := context.Background()

  	client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
          BusinessID: "<BUSINESS_ID>",
          SecretKey: "<SECRET_KEY>",
      })

      data := swervpay.FxBody{
          Amount: 100,
          Currency: "NGN",
          To: "USD"
      }

  	resp, err := client.Fx.Exchange(ctx, data)

  	if err != nil {
  		log.Fatal("error", err.Error())
  		return
  	}
  }
  ```
</RequestExample>


## OpenAPI

````yaml POST /fx/exchange
openapi: 3.0.0
info:
  title: Swervpay Developer API Specification
  version: 0.0.0
servers:
  - url: https://api.swervpay.co/api/v1
    description: Production API
  - url: https://sandbox.swervpay.co/api/v1
    description: Sandbox API
security:
  - bearerAuth: []
paths:
  /fx/exchange:
    post:
      tags:
        - fx.exchange
      description: Create exchange
      operationId: createExchange
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TypesCreateExchangeRateInput'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TypesBusinessTransaction'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsererrorError'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsererrorError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsererrorError'
components:
  schemas:
    TypesCreateExchangeRateInput:
      type: object
      properties:
        amount:
          type: number
        from:
          type: string
        to:
          type: string
    TypesBusinessTransaction:
      type: object
      properties:
        account_name:
          type: string
        account_number:
          type: string
        amount:
          type: number
        bank_code:
          type: string
        bank_name:
          type: string
        category:
          type: string
        charges:
          type: number
        created_at:
          type: string
          format: date-time
        detail:
          type: string
        fiat_rate:
          type: number
        id:
          type: string
        imad:
          type: string
        payment_method:
          type: string
        reference:
          type: string
        report:
          type: boolean
        report_message:
          type: string
        session_id:
          type: string
        status:
          type: string
        trace_number:
          type: string
        type:
          type: string
        updated_at:
          type: string
          format: date-time
    UsererrorError:
      type: object
      properties:
        message:
          type: string
        values:
          type: object
          additionalProperties: {}
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````