Skip to main content
POST
/
directory
/
api
/
4.0
/
work-contracts
Create a work-contract
curl --request POST \
  --url https://{host}/directory/api/4.0/work-contracts \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "ownerId": 89,
  "startsOn": "2022-01-19",
  "establishmentId": 1,
  "spcId": 0,
  "typeId": 1,
  "hiringTypeId": 1,
  "trialPeriodDays": 120,
  "renewedTrialPeriodDays": 240,
  "externalId": "123",
  "endsOn": "2022-02-10",
  "terminationReasonId": 27
}
'
import requests

url = "https://{host}/directory/api/4.0/work-contracts"

payload = {
"ownerId": 89,
"startsOn": "2022-01-19",
"establishmentId": 1,
"spcId": 0,
"typeId": 1,
"hiringTypeId": 1,
"trialPeriodDays": 120,
"renewedTrialPeriodDays": 240,
"externalId": "123",
"endsOn": "2022-02-10",
"terminationReasonId": 27
}
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({
ownerId: 89,
startsOn: '2022-01-19',
establishmentId: 1,
spcId: 0,
typeId: 1,
hiringTypeId: 1,
trialPeriodDays: 120,
renewedTrialPeriodDays: 240,
externalId: '123',
endsOn: '2022-02-10',
terminationReasonId: 27
})
};

fetch('https://{host}/directory/api/4.0/work-contracts', 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}/directory/api/4.0/work-contracts",
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([
'ownerId' => 89,
'startsOn' => '2022-01-19',
'establishmentId' => 1,
'spcId' => 0,
'typeId' => 1,
'hiringTypeId' => 1,
'trialPeriodDays' => 120,
'renewedTrialPeriodDays' => 240,
'externalId' => '123',
'endsOn' => '2022-02-10',
'terminationReasonId' => 27
]),
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}/directory/api/4.0/work-contracts"

payload := strings.NewReader("{\n \"ownerId\": 89,\n \"startsOn\": \"2022-01-19\",\n \"establishmentId\": 1,\n \"spcId\": 0,\n \"typeId\": 1,\n \"hiringTypeId\": 1,\n \"trialPeriodDays\": 120,\n \"renewedTrialPeriodDays\": 240,\n \"externalId\": \"123\",\n \"endsOn\": \"2022-02-10\",\n \"terminationReasonId\": 27\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}/directory/api/4.0/work-contracts")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"ownerId\": 89,\n \"startsOn\": \"2022-01-19\",\n \"establishmentId\": 1,\n \"spcId\": 0,\n \"typeId\": 1,\n \"hiringTypeId\": 1,\n \"trialPeriodDays\": 120,\n \"renewedTrialPeriodDays\": 240,\n \"externalId\": \"123\",\n \"endsOn\": \"2022-02-10\",\n \"terminationReasonId\": 27\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{host}/directory/api/4.0/work-contracts")

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 \"ownerId\": 89,\n \"startsOn\": \"2022-01-19\",\n \"establishmentId\": 1,\n \"spcId\": 0,\n \"typeId\": 1,\n \"hiringTypeId\": 1,\n \"trialPeriodDays\": 120,\n \"renewedTrialPeriodDays\": 240,\n \"externalId\": \"123\",\n \"endsOn\": \"2022-02-10\",\n \"terminationReasonId\": 27\n}"

response = http.request(request)
puts response.read_body
{
  "id": 514,
  "ownerId": 416,
  "startsOn": "2021-01-01",
  "endsOn": null,
  "isApplicable": true,
  "establishmentId": 13,
  "spcId": 1,
  "typeId": 1,
  "hiringTypeId": 3,
  "terminationReasonId": null,
  "trialPeriodDays": 120,
  "renewedTrialPeriodDays": null,
  "trialPeriodEndDate": "2021-05-01",
  "trialPeriodEndDate2": null,
  "authorId": 45,
  "lastModifierId": 45,
  "createdAt": "2021-11-08T17:48:18.12",
  "lastModifiedAt": "2024-01-10T12:27:02.22"
}

Headers

Authorization
string
required

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

Body

application/json
ownerId
integer

Unique identifier of the employee this work-contract belongs to.

Required range: x >= 1
externalId
string | null

Third-party identifier of this work-contract. May be not unique.

typeId
integer

Identifier of the work-contract template this work-contract conforms to. Determines whether certain optional properties are required.

startsOn
string<date>

Start date of this work-contract. Format: YYYY-mm-DD.

establishmentId
integer

Identifier of the establishment the employee works for.

spcId
integer | null

Identifier of the socio-professional category.

Refer to the API endpoint: /organization/structure/api/occupation-categories.

hiringTypeId
integer | null

Identifier of a hiring reason type.

Refer to the API endpoint: /directory/api/work-contract-hiring-types.

trialPeriodDays
integer | null

Number of days of the initial trial period.

Required range: x >= 0
renewedTrialPeriodDays
integer | null

Number of days of renewed trial period (equal to the length of the initial period, plus the renewal period).

Required range: x >= 0
trialPeriodEndDate
string<date> | null

Initial trial period end date. Format: YYYY-mm-DD.

trialPeriodEndDate2
string<date> | null

Renewed trial period end date. Format: YYYY-mm-DD.

temporaryContractGroundId
integer | null

Identifier of the temporary contract ground.

Refer to the API endpoint: /directory/api/work-contract-temporary-contract-grounds.

internshipSupervisorId
integer | null

Identifier of the employee/user that acts as internship supervisor.

endsOn
string<date> | null

End date of this work-contract. Leave null if not (yet) known. Format: YYYY-mm-DD.

terminationReasonId
integer | null

Identifier of the termination reason.

Refer to the API endpoint: /directory/api/work-contract-termination-reasons.

Response

OK

id
integer
read-only

Unique identifier of this work-contract.

Required range: x >= 1
ownerId
integer

Unique identifier of the employee this work-contract belongs to.

Required range: x >= 1
externalId
string | null

Third-party identifier of this work-contract. May be not unique.

typeId
integer

Identifier of the work-contract template this work-contract conforms to. Determines whether certain optional properties are required.

startsOn
string<date>

Start date of this work-contract. Format: YYYY-mm-DD.

isApplicable
boolean
read-only

Readonly. Whether this work-contract applies to the employee at this very moment.

A work-contract is considered "applicable" if:

  1. It is the ongoing work-contract as of today;
  2. If there is none, then it is the first upcoming work-contract;
  3. If not, then it is the last work-contract this employee had.
establishmentId
integer

Identifier of the establishment the employee works for.

spcId
integer | null

Identifier of the socio-professional category.

Refer to the API endpoint: /organization/structure/api/occupation-categories.

hiringTypeId
integer | null

Identifier of a hiring reason type.

Refer to the API endpoint: /directory/api/work-contract-hiring-types.

trialPeriodDays
integer | null

Number of days of the initial trial period.

Required range: x >= 0
renewedTrialPeriodDays
integer | null

Number of days of renewed trial period (equal to the length of the initial period, plus the renewal period).

Required range: x >= 0
trialPeriodEndDate
string<date> | null

Initial trial period end date. Format: YYYY-mm-DD.

trialPeriodEndDate2
string<date> | null

Renewed trial period end date. Format: YYYY-mm-DD.

temporaryContractGroundId
integer | null

Identifier of the temporary contract ground.

Refer to the API endpoint: /directory/api/work-contract-temporary-contract-grounds.

internshipSupervisorId
integer | null

Identifier of the employee/user that acts as internship supervisor.

endsOn
string<date> | null

End date of this work-contract. Leave null if not (yet) known. Format: YYYY-mm-DD.

terminationReasonId
integer | null

Identifier of the termination reason.

Refer to the API endpoint: /directory/api/work-contract-termination-reasons.

authorId
integer
read-only

Read-only. Identifier of the user who created this work-contract.

createdAt
string<date-time>
read-only

Read-only. Timestamp of the moment this work-contract was created.

lastModifierId
integer
read-only

Read-only. Identifier of the user who last modified this work-contract.

lastModifiedAt
string<date-time>
read-only

Read-only. Timestamp of the moment this work-contract was last updated.