Create a Currency

Last updated 7 months ago

post
Create a Currency

https://api.moltin.com
/v2/currencies
Request
Response
Headers
Authorization
required
string
The Bearer token to grant access to the API
Body Parameters
enabled
required
boolean
Is this currency available for products? true or false
default
required
boolean
Is this the default currency? true or false
decimal_places
required
string
How many decimal places the currency is formatted to
thousand_separator
required
string
The thousand separator character. Example: ,
decimal_point
required
string
The decimal point character. Example: .
format
required
string
Specify how the price currency is displayed. Example: "¥{price}"
exchange_rate
required
integer
The exchange rate from the default currency
code
required
string
The currency code. Example: YEN
type
required
string
The type represents the object being returned
201: Created
{
"data": {
"id": "190c3e9e-8006-4231-8c29-833fb4f6bff0",
"type": "currency",
"code": "YEN",
"exchange_rate": 1,
"format": "¥{price}",
"decimal_point": ",",
"thousand_separator": ".",
"decimal_places": 2,
"default": false,
"enabled": true,
"links": {
"self":
"https://api.moltin.com/currencies/190c3e9e-8006-4231-8c29-833fb4f6bff0"
},
"meta": {
"timestamps": {
"created_at": "2018-05-02T09:01:56.303640168Z",
"updated_at": "2018-05-02T09:01:56.303641068Z"
}
}
}
}
400: Bad Request
You'll get an error if you try to create a currency with an existing code
{
"errors": [
{
"status": 400,
"title": "Currency already exists",
"detail": "The specified currency code already exists for this store"
}
]
}
cURL
JavaScript SDK
curl -X POST https://api.moltin.com/v2/currencies \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": {
"type": "currency",
"code": "YEN",
"exchange_rate": 1,
"format": "¥{price}",
"decimal_point": ".",
"thousand_separator": ",",
"decimal_places": 2,
"default": false,
"enabled": true
}
}'
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X',
client_secret: 'X'
})
const currency = {
code: 'YEN',
exchange_rate: 1,
format: '¥{price}',
decimal_point: '.',
thousand_separator: ',',
decimal_places: 2,
default: false,
enabled: true
}
Moltin.Currencies.Create(id, currency).then(currency => {
// Do something
})