# Creates a new absence period. Creates a new absence period. # OpenAPI definition ```json { "openapi": "3.0.3", "info": { "title": "Absence Period API", "version": "2.0.0", "description": "Read API for Absence Entities." }, "servers": [ { "url": "https://api.personio.de" } ], "security": [ { "BearerAuth": [] } ], "tags": [ { "name": "Absence Periods", "description": "Endpoints related to absences taken by employees and the rules that define them." } ], "paths": { "/v2/absence-periods": { "post": { "summary": "Creates a new absence period.", "description": "Creates a new absence period.", "tags": [ "Absence Periods" ], "parameters": [ { "$ref": "#/components/parameters/SkipApprovalQueryParam" } ], "x-path-examples": { "201 Valid request": { "value": "/papi/v2/absence-periods", "query": "skip_approval=false" }, "400 Invalid JSON": { "value": "/papi/v2/absence-periods", "query": "skip_approval=false" }, "403 Forbidden": { "value": "/papi/v2/absence-periods", "query": "skip_approval=false" }, "409 Absence period conflict": { "value": "/papi/v2/absence-periods", "query": "skip_approval=false" }, "409 Requesting absence while substituting": { "value": "/papi/v2/absence-periods", "query": "skip_approval=false" }, "409 Substitute is invalid": { "value": "/papi/v2/absence-periods", "query": "skip_approval=false" }, "422 Unprocessable absence period request": { "value": "/papi/v2/absence-periods", "query": "skip_approval=false" }, "422 Substitute not allowed": { "value": "/papi/v2/absence-periods", "query": "skip_approval=false" }, "422 Substitute required": { "value": "/papi/v2/absence-periods", "query": "skip_approval=false" } }, "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PostAbsencePeriodRequest" }, "examples": { "201 Valid request": { "$ref": "#/components/examples/PostAbsencePeriodRequest" }, "400 Invalid JSON": { "value": { "random": "INVALID_JSON" } }, "403 Forbidden": { "$ref": "#/components/examples/PostAbsencePeriodRequest" }, "409 Absence period conflict": { "$ref": "#/components/examples/PostAbsencePeriodRequest" }, "409 Requesting absence while substituting": { "value": { "person": { "id": "12345" }, "starts_from": { "date_time": "2022-01-01T00:00:00.000", "type": "FIRST_HALF" }, "ends_at": { "date_time": "2022-01-03T00:00:00.000", "type": "SECOND_HALF" }, "absence_type": { "id": "137a2048-41e9-4d49-9201-e6a032521495" } } }, "409 Substitute is invalid": { "value": { "person": { "id": "12345" }, "starts_from": { "date_time": "2022-01-01T00:00:00.000", "type": "FIRST_HALF" }, "ends_at": { "date_time": "2022-01-03T00:00:00.000", "type": "SECOND_HALF" }, "absence_type": { "id": "137a2048-41e9-4d49-9201-e6a032521495" }, "substitute": { "id": "invalid-substitute-id" } } }, "422 Unprocessable absence period request": { "value": { "person": { "id": "12345" }, "starts_from": { "date_time": "2022-01-01T00:00:00.000", "type": "FIRST_HALF" }, "ends_at": { "date_time": "2021-01-01T00:00:00.000", "type": "SECOND_HALF" }, "comment": "This period has an end time before the start time", "absence_type": { "id": "137a2048-41e9-4d49-9201-e6a032521495" } } }, "422 Substitute not allowed": { "value": { "person": { "id": "12345" }, "starts_from": { "date_time": "2022-01-01T00:00:00.000", "type": "FIRST_HALF" }, "ends_at": { "date_time": "2022-01-03T00:00:00.000", "type": "SECOND_HALF" }, "absence_type": { "id": "137a2048-41e9-4d49-9201-e6a032521495" }, "substitute": { "id": "54321" } } }, "422 Substitute required": { "value": { "person": { "id": "12345" }, "starts_from": { "date_time": "2022-01-01T00:00:00.000", "type": "FIRST_HALF" }, "ends_at": { "date_time": "2022-01-03T00:00:00.000", "type": "SECOND_HALF" }, "absence_type": { "id": "137a2048-41e9-4d49-9201-e6a032521495" } } } } } } }, "responses": { "201": { "description": "The absence period was successfully created.", "content": { "application/json": { "schema": { "description": "This is an object that is returned whenever a new resource is created. It contains the unique identifier for the created resource and optionally a link that can be used to retrieve it.", "properties": { "id": { "readOnly": true, "type": "string", "example": "some-random-id", "description": "The id of the created resource." }, "_meta": { "$ref": "#/paths/~1v2~1absence-types/get/responses/200/content/application~1json/schema/properties/_meta" } } }, "examples": { "201 Valid request": { "value": { "id": "fd19f19d-a272-4ea5-b46a-07ecdfc05be3", "_meta": { "links": { "self": { "href": "https://api.personio.de/v2/absence-periods/fd19f19d-a272-4ea5-b46a-07ecdfc05be3" } } } } } } } } }, "400": { "$ref": "#/components/responses/BadRequestInvalidJsonErrorResponse" }, "403": { "$ref": "#/components/responses/ForbiddenErrorResponse" }, "409": { "$ref": "#/components/responses/AbsencePeriodConflictErrorResponse" }, "422": { "$ref": "#/components/responses/AbsencePeriodUnprocessableErrorResponse" } } } } }, "components": { "securitySchemes": { "BearerAuth": { "type": "http", "scheme": "bearer" } }, "examples": { "PostAbsencePeriodRequest": { "value": { "person": { "id": "12345" }, "starts_from": { "date_time": "2022-01-01T00:00:00.000", "type": "FIRST_HALF" }, "ends_at": { "date_time": "2022-01-03T00:00:00.000", "type": "SECOND_HALF" }, "comment": "A valid comment", "absence_type": { "id": "137a2048-41e9-4d49-9201-e6a032521495" }, "substitute": { "id": "54321" } } } }, "parameters": { "SkipApprovalQueryParam": { "name": "skip_approval", "in": "query", "description": "If true, skip any approval that this write request would otherwise require.", "required": false, "schema": { "type": "boolean", "default": false, "example": false } } }, "schemas": { "PersonId": { "type": "object", "description": "ID of a Person.", "required": [ "id" ], "properties": { "id": { "type": "string", "description": "A unique identifier for a Person." } } }, "AbsenceTypeId": { "type": "object", "description": "ID of an Absence Type.", "required": [ "id" ], "properties": { "id": { "type": "string", "description": "A unique identifier for an Absence Type." } } }, "DateTimeWithoutTimezone": { "type": "string", "example": "2022-01-01T14:00:00.000", "description": "An RFC3339 date and timestamp without a timezone offset." }, "PostAbsencePeriodRequest": { "type": "object", "description": "A request to create a new absence period.", "required": [ "person", "starts_from", "absence_type" ], "properties": { "person": { "$ref": "#/components/schemas/PersonId" }, "starts_from": { "description": "This object represents the beginning of the absence period.\n\nSee the documentation of the `AbsencePeriod` response for a full description of these fields. In particular,\nnote that:\n * the validity of a particular time range depends on the `unit` of the `AbsenceType` (hourly or daily)\n * The times should be local times in the timezone specified by the `timezone_id` field\n * No timezone offset should be included (e.g no \"+00:00\" or \"Z\" suffix)\n", "type": "object", "required": [ "date_time" ], "properties": { "date_time": { "$ref": "#/components/schemas/DateTimeWithoutTimezone" }, "type": { "type": "string", "nullable": true, "enum": [ "FIRST_HALF", "SECOND_HALF" ], "example": "FIRST_HALF", "description": "Determines whether this period starts from the first half or second half of the day. See the description\nof the `starts_from` field for a detailed explanation.\n" } } }, "ends_at": { "description": "This object represents the end of the absence period. It may be null for periods which are\nongoing and do not have a defined end. For example, `ends_at` will generally be unknown for long term sick\nleave.\n", "type": "object", "required": [ "date_time" ], "nullable": true, "properties": { "date_time": { "$ref": "#/components/schemas/DateTimeWithoutTimezone" }, "type": { "type": "string", "nullable": true, "enum": [ "FIRST_HALF", "SECOND_HALF" ], "example": "SECOND_HALF", "description": "Determines whether this period ends after the first half or second half of the day. See the\ndescription of the `starts_from` field for a detailed explanation.\n" } } }, "comment": { "type": "string", "nullable": true, "maxLength": 2000, "description": "A comment attached to this period.", "example": "Going on vacation to Hawaii." }, "absence_type": { "$ref": "#/components/schemas/AbsenceTypeId" }, "substitute": { "nullable": true, "type": "object", "description": "The person who will be covering for the person taking this absence. This field is only meaningful if the\npolicy of the absence type allows substitutes.\n", "properties": { "id": { "type": "string", "description": "A unique identifier for a Person." } } } } } }, "responses": { "BadRequestInvalidJsonErrorResponse": { "description": "Bad request.", "content": { "application/problem+json": { "schema": { "$ref": "#/components/responses/ForbiddenErrorResponse/content/application~1problem%2Bjson/schema" }, "examples": { "400 Invalid JSON": { "value": { "personio_trace_id": "8b46fa09-d8fe-4de0-be03-f0a1d48df766", "timestamp": "2021-05-28T11:17:30+00:00", "errors": [ { "title": "Input must be valid JSON", "detail": "The provided input is not a JSON object" } ] } } } } } }, "AbsencePeriodConflictErrorResponse": { "description": "Conflict.", "content": { "application/problem+json": { "schema": { "$ref": "#/components/responses/ForbiddenErrorResponse/content/application~1problem%2Bjson/schema" }, "examples": { "409 Absence period conflict": { "value": { "personio_trace_id": "8b46fa09-d8fe-4de0-be03-f0a1d48df766", "timestamp": "2021-05-28T11:17:30+00:00", "errors": [ { "title": "Overlapping absence period", "detail": "Absence period overlaps with at least one existing period" } ] } }, "409 Requesting absence while substituting": { "value": { "personio_trace_id": "8b46fa09-d8fe-4de0-be03-f0a1d48df766", "timestamp": "2021-05-28T11:17:30+00:00", "errors": [ { "title": "Requesting an absence while substituting for another absence", "detail": "Requesting an absence while substituting for another absence" } ] } }, "409 Substitute is invalid": { "value": { "personio_trace_id": "8b46fa09-d8fe-4de0-be03-f0a1d48df766", "timestamp": "2021-05-28T11:17:30+00:00", "errors": [ { "title": "Substitute is invalid", "detail": "Your selected substitute is not available in the selected time period." } ] } } } } } }, "AbsencePeriodUnprocessableErrorResponse": { "description": "Unprocessable request.", "content": { "application/problem+json": { "schema": { "$ref": "#/components/responses/ForbiddenErrorResponse/content/application~1problem%2Bjson/schema" }, "examples": { "422 Unprocessable absence period request": { "value": { "personio_trace_id": "8b46fa09-d8fe-4de0-be03-f0a1d48df766", "timestamp": "2021-05-28T11:17:30+00:00", "errors": [ { "title": "Time frame end is before start", "detail": "Time frame end is before time frame start" } ] } }, "422 Substitute not allowed": { "value": { "personio_trace_id": "8b46fa09-d8fe-4de0-be03-f0a1d48df766", "timestamp": "2021-05-28T11:17:30+00:00", "errors": [ { "title": "Substitute not allowed", "detail": "A substitute is not allowed for this absence type." } ] } }, "422 Substitute required": { "value": { "personio_trace_id": "8b46fa09-d8fe-4de0-be03-f0a1d48df766", "timestamp": "2021-05-28T11:17:30+00:00", "errors": [ { "title": "Substitute required", "detail": "A substitute is required for this absence type." } ] } } } } } }, "ForbiddenErrorResponse": { "description": "Access to this endpoint is denied.", "content": { "application/problem+json": { "schema": { "type": "object", "description": "This object represents an error response.", "properties": { "personio_trace_id": { "type": "string", "example": "aswo3f-a202lfso-312123sld-1230ddd", "description": "A unique ID that was created for this error." }, "timestamp": { "type": "string", "format": "date-time", "example": "2021-05-28T11:17:30.000Z", "description": "The timestamp of when the error occurred." }, "errors": { "type": "array", "items": { "type": "object", "properties": { "title": { "type": "string", "example": "Not found", "description": "The title of the error." }, "detail": { "type": "string", "example": "The requested resource was not found.", "description": "A short description about the error." }, "type": { "type": "string", "format": "uri", "example": "https://developer.personio.de/reference/errors#common.requested_resource_not_found", "description": "A link to the developer hub where more information can be found for the encountered error." }, "_meta": { "type": "object", "additionalProperties": { "type": "string" } } } } } } }, "examples": { "403 Forbidden": { "value": { "personio_trace_id": "8b46fa09-d8fe-4de0-be03-f0a1d48df766", "timestamp": "2021-05-28T11:17:30Z", "errors": [ { "title": "Access Denied", "detail": "Access to this endpoint is denied." } ] } } } } } } } } } ```