Skip to main content
POST
/
cleemy-procurement
/
api
/
costcenters
Create a Cost-Center
curl --request POST \
  --url https://{host}/cleemy-procurement/api/costcenters \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "code": "<string>",
  "ownerId": 123,
  "owner": {
    "id": 123
  },
  "state": "Disabled",
  "establishmentIds": [
    123
  ]
}
'
import requests

url = "https://{host}/cleemy-procurement/api/costcenters"

payload = {
"name": "<string>",
"code": "<string>",
"ownerId": 123,
"owner": { "id": 123 },
"state": "Disabled",
"establishmentIds": [123]
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
code: '<string>',
ownerId: 123,
owner: {id: 123},
state: 'Disabled',
establishmentIds: [123]
})
};

fetch('https://{host}/cleemy-procurement/api/costcenters', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://{host}/cleemy-procurement/api/costcenters",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'code' => '<string>',
'ownerId' => 123,
'owner' => [
'id' => 123
],
'state' => 'Disabled',
'establishmentIds' => [
123
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://{host}/cleemy-procurement/api/costcenters"

payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"code\": \"<string>\",\n \"ownerId\": 123,\n \"owner\": {\n \"id\": 123\n },\n \"state\": \"Disabled\",\n \"establishmentIds\": [\n 123\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://{host}/cleemy-procurement/api/costcenters")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"code\": \"<string>\",\n \"ownerId\": 123,\n \"owner\": {\n \"id\": 123\n },\n \"state\": \"Disabled\",\n \"establishmentIds\": [\n 123\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{host}/cleemy-procurement/api/costcenters")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"code\": \"<string>\",\n \"ownerId\": 123,\n \"owner\": {\n \"id\": 123\n },\n \"state\": \"Disabled\",\n \"establishmentIds\": [\n 123\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "items": [
    {
      "name": "<string>",
      "code": "<string>",
      "id": 123,
      "owner": {
        "id": 123,
        "href": "<string>",
        "name": "<string>",
        "firstName": "<string>",
        "lastName": "<string>",
        "pictureHref": "<string>"
      },
      "state": "Disabled",
      "establishments": [
        {
          "id": 123,
          "name": "<string>",
          "href": "<string>"
        }
      ]
    }
  ]
}

Headers

Authorization
string
required

API key. Value must be formatted like so: lucca application={api_key}.

Body

application/json

Cost-center to create.

Cost-center.

name
string
required
code
string
required
ownerId
integer<int32>
write-only

ID of the user who will be the owner of the cost-center.

owner
Reference to a user · object

Read-only. Owner of the cost-center.

state
enum<string>
default:Disabled

Disabled: the cost-center is disabled. Enabled: the cost-center is enabled.

Available options:
Disabled,
Enabled
establishmentIds
integer<int32>[]
write-only

Write-only. IDs of the establishments to which the cost-center belongs."

Response

201 - application/json

OK

items
cost-center · object[]