Create a Country
Endpoint Overview
This API endpoint provides a detailed overview of the endpoint responsible for creating a country within the Resources module of the Juleb ERP.
Endpoint Details
- Method: POST
- URL:
/api/v1/resources/res-country
Parameters
- Path Parameters: None
- Query Parameters: None
Request Body
{
"name": string,
"code": string,
"address_format": string,
"phone_code": integer,
"name_position": string,
"vat_label": string
}
Field Reference
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Country name. |
code | string | No | ISO country code (2 characters). |
address_format | string | No | Address format template used when printing documents. |
phone_code | integer | No | International dialing code. |
name_position | string | No | Name position format (e.g. for address layout). |
vat_label | string | No | VAT label used for this country (e.g. "VAT", "TRN"). |
Response
- 201 OK: Successfully created the record.
- 400 Bad Request: Bad request.
- 401 Unauthorized: Unauthorized.
Response Body
{
"data": {
...record fields
}
}
Example
Request
- NodeJS
- curl
- python
- java
const axios = require('axios');
const accountName = process.env.ACCOUNT_NAME;
const apiKey = process.env.API_KEY;
axios.post(`https://${accountName}.juleb.com/api/v1/resources/res-country`, {
name: 'Saudi Arabia',
code: 'SA',
phone_code: 966,
vat_label: 'VAT'
}, {
headers: {
accept: '*/*',
Authorization: `TOKEN`,
'Content-Type': 'application/json'
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error);
});
curl -X POST \
-H "accept: */*" \
-H "Authorization: ******" \
-H "Content-Type: application/json" \
-d '{
"name": "Saudi Arabia",
"code": "SA",
"phone_code": 966,
"vat_label": "VAT"
}' \
"https://$ACCOUNT_NAME.juleb.com/api/v1/resources/res-country"
import os
import requests
account_name = os.getenv('ACCOUNT_NAME')
api_key = os.getenv('API_KEY')
url = f'https://{account_name}.juleb.com/api/v1/resources/res-country'
headers = {
'accept': '*/*',
'Authorization': f'******',
'Content-Type': 'application/json'
}
data = {
'name': 'Saudi Arabia',
'code': 'SA',
'phone_code': 966,
'vat_label': 'VAT'
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 201:
print(response.json())
else:
print(f'Error: {response.status_code}', response.text)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
public class Main {
public static void main(String[] args) throws Exception {
String accountName = System.getenv("ACCOUNT_NAME");
String apiKey = System.getenv("API_KEY");
String json = "{"
+ "\"name\": \"Saudi Arabia\","
+ "\"code\": \"SA\","
+ "\"phone_code\": 966,"
+ "\"vat_label\": \"VAT\""
+ "}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("https://" + accountName + ".juleb.com/api/v1/resources/res-country"))
.header("accept", "*/*")
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
if (response.statusCode() == 201) {
System.out.println(response.body());
} else {
System.out.println("Error: " + response.statusCode() + ", " + response.body());
}
}
}
Response
{
"data": {
"id": 193,
"name": "Saudi Arabia",
"code": "SA",
"phone_code": 966,
"vat_label": "VAT"
}
}