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

# Create Currency Exchanges

> Creates currency exchange rates in batch (up to 20 records per request)

Creates currency exchange rates in your COR instance through the integrations service. This endpoint processes multiple exchange rates in a single request and provides detailed feedback about successes, duplicates, and errors.

<Note>
  **Batch Processing**: You can submit up to 20 currency exchange records per request. The endpoint will process all records and return detailed statistics about the operation.
</Note>

## Request Body Requirements

<ParamField body="metadata" type="object" required>
  <Expandable title="properties">
    <ParamField body="source" type="string" required>
      Integration source identifier. Must be one of: `JIRA`, `SALESFORCE`, `ADVERTMIND`, `QUICKBOOKS`, `ZAPIER`, `OKTA`, `MICROSOFT_DYNAMICS`, `GITHUB`, `MICROSOFT_TEAMS`, `VBS`, `SAP`, `GLOBANT`
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="currency_exchanges" type="array" required>
  Array of currency exchange rates (maximum 20 items)

  <Expandable title="items">
    <ParamField body="foreign_currency" type="string" required>
      Foreign currency ISO code (e.g., "USD", "EUR")
    </ParamField>

    <ParamField body="base_currency" type="string" required>
      Base currency ISO code - must match your company's base currency
    </ParamField>

    <ParamField body="amount" type="number" required>
      Exchange rate amount
    </ParamField>

    <ParamField body="factor" type="number" required>
      Exchange rate factor (typically 1)
    </ParamField>

    <ParamField body="effective_date" type="string" required>
      ISO 8601 datetime when the rate becomes effective (e.g., "2025-03-20T02:00:00Z")
    </ParamField>

    <ParamField body="end_date" type="string">
      ISO 8601 datetime when the rate expires (optional)
    </ParamField>

    <ParamField body="metadata" type="object">
      Additional metadata for the exchange rate

      <Expandable title="properties">
        <ParamField body="last_updated_datetime" type="string">
          ISO 8601 datetime of last update
        </ParamField>

        <ParamField body="rate_type" type="string">
          Rate type identifier (e.g., "EURX")
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

## Response

The endpoint returns statistics about the batch operation:

* `status` — Operation status: `success` (all records processed), `failed` (all records rejected), or `partial` (some succeeded, some failed)
* `company_id` — The unique identifier of the company associated with the request
* `records_received` — Total number of records in the request
* `records_deduplicated` — Number of duplicate records removed
* `records_created` — Number of successfully created records
* `records_replaced` — Number of records that replaced existing ones
* `records_rejected` — Number of records that failed validation or processing
* `errors` — Array of error details for rejected records

Each item in `errors` includes:

| Field           | Type   | Description                                                                |
| --------------- | ------ | -------------------------------------------------------------------------- |
| `from_currency` | string | Source/foreign currency ISO code of the rejected record                    |
| `to_currency`   | string | Base/target currency ISO code of the rejected record                       |
| `message`       | string | Validation or business-rule message explaining why the record was rejected |

## Known Errors

### Validation Errors

* `ValidationError` — Missing required fields or invalid structure
* Currency not found — The specified ISO code doesn't exist in the system
* Base currency mismatch — The base\_currency doesn't match your company's base currency

### Business Logic Errors

* Date mismatch — `effective_date` and `last_updated_datetime` must be on the same day (for GLOBANT source)
* Invalid exchange rate — Amount or factor values are invalid

<RequestExample>
  ```bash cURL theme={null}
  curl --location 'https://integrations.projectcor.com/v2/integrations/currency-exchanges' \
  --header 'Authorization: Bearer {{token}}' \
  --header 'Content-Type: application/json' \
  --data '{
    "currency_exchanges": [
      {
        "foreign_currency": "USD",
        "base_currency": "ARS",
        "amount": 100,
        "factor": 1,
        "effective_date": "2025-03-20T02:00:00Z",
        "metadata": {
          "last_updated_datetime": "2025-03-20T02:00:00Z",
          "rate_type": "EURX"
        }
      },
      {
        "foreign_currency": "EUR",
        "base_currency": "ARS",
        "amount": 110.50,
        "factor": 1,
        "effective_date": "2025-03-20T02:00:00Z",
        "metadata": {
          "last_updated_datetime": "2025-03-20T02:00:00Z",
          "rate_type": "EURX"
        }
      }
    ],
    "metadata": {
      "source": "GLOBANT"
    }
  }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://integrations.projectcor.com/v2/integrations/currency-exchanges"

  payload = {
      "currency_exchanges": [
          {
              "foreign_currency": "USD",
              "base_currency": "ARS",
              "amount": 100,
              "factor": 1,
              "effective_date": "2025-03-20T02:00:00Z",
              "metadata": {
                  "last_updated_datetime": "2025-03-20T02:00:00Z",
                  "rate_type": "EURX"
              }
          },
          {
              "foreign_currency": "EUR",
              "base_currency": "ARS",
              "amount": 110.50,
              "factor": 1,
              "effective_date": "2025-03-20T02:00:00Z",
              "metadata": {
                  "last_updated_datetime": "2025-03-20T02:00:00Z",
                  "rate_type": "EURX"
              }
          }
      ],
      "metadata": {
          "source": "GLOBANT"
      }
  }

  headers = {
      "Authorization": "Bearer {{token}}",
      "Content-Type": "application/json"
  }

  response = requests.post(url, json=payload, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://integrations.projectcor.com/v2/integrations/currency-exchanges',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer {{token}}',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        currency_exchanges: [
          {
            foreign_currency: 'USD',
            base_currency: 'ARS',
            amount: 100,
            factor: 1,
            effective_date: '2025-03-20T02:00:00Z',
            metadata: {
              last_updated_datetime: '2025-03-20T02:00:00Z',
              rate_type: 'EURX'
            }
          },
          {
            foreign_currency: 'EUR',
            base_currency: 'ARS',
            amount: 110.50,
            factor: 1,
            effective_date: '2025-03-20T02:00:00Z',
            metadata: {
              last_updated_datetime: '2025-03-20T02:00:00Z',
              rate_type: 'EURX'
            }
          }
        ],
        metadata: {
          source: 'GLOBANT'
        }
      })
    }
  );

  const data = await response.json();
  console.log(data);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "status": "success",
    "company_id": 2336,
    "records_received": 2,
    "records_deduplicated": 1,
    "records_created": 1,
    "records_replaced": 0,
    "records_rejected": 0,
    "errors": []
  }
  ```

  ```json 200 - Partial Success theme={null}
  {
    "status": "partial",
    "company_id": 2336,
    "records_received": 5,
    "records_deduplicated": 1,
    "records_created": 3,
    "records_replaced": 0,
    "records_rejected": 1,
    "errors": [
      {
        "from_currency": "USD",
        "to_currency": "ARS",
        "message": "metadata.last_updated_datetime day must match start date"
      }
    ]
  }
  ```

  ```json 200 - Failed theme={null}
  {
    "status": "failed",
    "company_id": 2336,
    "records_received": 2,
    "records_deduplicated": 1,
    "records_created": 0,
    "records_replaced": 0,
    "records_rejected": 1,
    "errors": [
      {
        "from_currency": "USD",
        "to_currency": "ARS",
        "message": "metadata.last_updated_datetime day must match start date"
      }
    ]
  }
  ```

  ```json 400 theme={null}
  {
    "status": 400,
    "name": "COR_CUSTOM_ERROR",
    "code": "ZC002",
    "message": "Source is required in metadata"
  }
  ```
</ResponseExample>
