# Add a new currency

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

This API is used to add a new currency to your Chargebee site. Prior to using this API, ensure that the [multi-currency feature](https://www.chargebee.com/docs/2.0/multi-currency-pricing.html#1-adding-and-managing-currencies) is enabled. If the `forex_type` is set to `manual` , you can specify the `manual_exchange_rate` . Additionally, the currency code provided must adhere to the three-letter ISO standard currency codes.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/currencies \
     -u {site_api_key}:\
     -d currency_code="EUR" \
     -d forex_type="MANUAL" \
     -d manual_exchange_rate="1.234784"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Currency.Create()
		.CurrencyCode("EUR")
		.ForexType(Currency.ForexTypeEnum.Manual)
		.ManualExchangeRate("1.234784")
		.Request();

Currency currency = result.Currency;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    currencyAction "github.com/chargebee/chargebee-go/v3/actions/currency"
    "github.com/chargebee/chargebee-go/v3/models/currency"
    currencyEnum "github.com/chargebee/chargebee-go/v3/models/currency/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := currencyAction.Create(&currency.CreateRequestParams{
        CurrencyCode : "EUR",
        ForexType : currencyEnum.ForexTypeManual,
        ManualExchangeRate : "1.234784",
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Currency := res.Currency
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.CurrencyCreateRequest{
    CurrencyCode : "EUR",
    ForexType : chargebee.CurrencyForexTypeManual,
    ManualExchangeRate : "1.234784",
}
  res, err := client.Currency.Create(req)
      if err != nil {
        fmt.Println(err)
    } else {
        Currency := res.Currency
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Currency.create()
            .currencyCode("EUR")
            .forexType(Currency.ForexType.MANUAL)
            .manualExchangeRate("1.234784")
            .request();

        Currency currency = result.currency();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.currency.Currency;
import com.chargebee.v4.models.currency.params.CurrencyCreateParams;
import com.chargebee.v4.models.currency.responses.CurrencyCreateResponse;

public class CurrencyCreate {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        CurrencyCreateParams params = CurrencyCreateParams.builder()
            .currencyCode("EUR")
            .forexType(CurrencyCreateParams.ForexType.MANUAL)
            .manualExchangeRate("1.234784")
            .build();

        CurrencyCreateResponse response = client.currencies().create(params);

        Currency currency = response.getCurrency();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.currency.create({
        currency_code: "EUR",
        forex_type: "manual",
        manual_exchange_rate: "1.234784"
    });

    console.log(result);
    const currency = result.currency;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->currency()->create([
    "currency_code" => "EUR",
    "forex_type" => "manual",
    "manual_exchange_rate" => "1.234784"
]);
$currency = $result->currency;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Currency.create(
    cb_client.Currency.CreateParams(
        currency_code="EUR",
        forex_type=chargebee.Currency.ForexType.MANUAL,
        manual_exchange_rate="1.234784"
    )
)
currency = response.currency
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Currency.create({
  :currency_code => "EUR",
  :forex_type => "MANUAL",
  :manual_exchange_rate => "1.234784"
})

currency = result.currency
```

## Sample Response

```json
{
  "currency": {
    "id": "cur_XpbNwDtU56AzUh3j",
    "currency_code": "EUR",
    "is_base_currency": false,
    "forex_type": "manual",
    "manual_exchange_rate": "1.234784"
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/currencies

## Input Parameters

- `currency_code` (required, string, max chars=3)
  A three letter currency code. For example, GBR, INR, and more.

- `forex_type` (required, enumerated string)
  This represents the exchange rate type set for the currency.
  Possible enum values:
    - `manual`
      If `forex_type` is `manual` , you will be able to set the conversion rate for the currency. You need to update the exchange rate each time your exchange rate provider changes it
    - `auto`
      If `forex_type` is `auto` , conversion rate will be auto updated by Chargebee every day with third party providers (using external currency conversion providers)

- `manual_exchange_rate` (optional, string, max chars=20)
  This parameter allows you to pass the exchange rate in decimal format. When `forex_type` is `manual` you have to set the exchange rate for additional currencies in `manual_exchange_rate` parameter. A maximum of **nine** decimal values are allowed to pass in this field.

## Returns

- `currency` (Currency object)
  Resource object representing currency
