> For the complete documentation index, see [llms.txt](https://docs.hiboo.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hiboo.io/rest-api-reference/contracts.md).

# Contracts

The following endpoints allow you to assign your equipments to contracts data, so that Hiboo can detect out-of-contract usages.

## List contract assignments

> Returns all the contract assignments of your organization

```json
{"openapi":"3.0.3","info":{"title":"Hiboo API","version":"2.0.0"},"tags":[{"name":"Contracts","description":"The following endpoints allow you to assign your equipments to contracts data, so that Hiboo can detect out-of-contract usages."}],"servers":[{"url":"https://api.hiboo.io","description":"Production server"},{"url":"https://api-sandbox.hiboo.io","description":"Sandbox server"}],"security":[{"JWT":[]}],"components":{"securitySchemes":{"JWT":{"type":"apiKey","in":"header","name":"x-access-token","description":"Generate a JWT when you log in. Use it in your following requests in the header as `x-access-token: your-token-here`\n"}},"schemas":{"ContractAssignment":{"required":["id","contractReference","assetId","startDate","endDate","maximumHoursPerDay","customer","workingDays","excludedDays","includedDays","excludePublicHolidays","country","dailyRate","currency"],"type":"object","properties":{"id":{"description":"Unique identifier of the contract assignment, generated by Hiboo","type":"integer","format":"int32"},"contractReference":{"description":"The reference of the contract the equipment is assigned to","type":"string"},"assetId":{"description":"Hiboo's id of the equipment assigned to the contract","type":"integer","format":"int32"},"startDate":{"description":"First day of the contract assignment (YYYY-MM-DD), asset timezone","type":"string","format":"date"},"endDate":{"description":"Last day of the contract assignment (YYYY-MM-DD), asset timezone. Must not be before the start date","type":"string","format":"date"},"maximumHoursPerDay":{"description":"Maximum number of usage hours per day allowed by the contract. `null` if the contract does not limit the daily usage","type":"number","nullable":true},"customer":{"description":"Name of the customer renting the equipment","type":"string"},"workingDays":{"description":"Days of the week on which the equipment is expected to be used under the contract","type":"array","minItems":1,"items":{"type":"string","enum":["monday","tuesday","wednesday","thursday","friday","saturday","sunday"]}},"excludedDays":{"description":"Specific dates (YYYY-MM-DD) excluded from the contract, even if they fall on a working day","type":"array","items":{"type":"string","format":"date"}},"includedDays":{"description":"Specific dates (YYYY-MM-DD) included in the contract, even if they do not fall on a working day","type":"array","items":{"type":"string","format":"date"}},"excludePublicHolidays":{"description":"If true, public holidays of the specified country are excluded from the contract","type":"boolean"},"country":{"description":"Country used to determine public holidays","type":"string","enum":["FR","GB"]},"dailyRate":{"description":"Daily rate charged for out-of-contract usage. `null` if not defined","type":"number","nullable":true},"currency":{"description":"Currency of the daily rate, as a 3-letter ISO 4217 code","type":"string","minLength":3,"maxLength":3}}},"NoDetailError":{"required":["message"],"type":"object","properties":{"message":{"type":"string","description":"A human readable description of the error"}}}},"responses":{"401Error":{"description":"Unable to authenticate the token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NoDetailError"}}}},"403Error":{"description":"Insufficient permissions to access the resource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NoDetailError"}}}}}},"paths":{"/v2/fleet/contracts/assignments":{"get":{"tags":["Contracts"],"summary":"List contract assignments","description":"Returns all the contract assignments of your organization","operationId":"listContractAssignments","responses":{"200":{"description":"Successful operation","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ContractAssignment"}}}}},"401":{"$ref":"#/components/responses/401Error"},"403":{"$ref":"#/components/responses/403Error"}}}}}}
```

## Create a contract assignment

> Assigns an equipment to a contract for a given period. The contract assignment defines the expected usage of the equipment (working days, maximum hours per day), which is used to detect out-of-contract usage.

```json
{"openapi":"3.0.3","info":{"title":"Hiboo API","version":"2.0.0"},"tags":[{"name":"Contracts","description":"The following endpoints allow you to assign your equipments to contracts data, so that Hiboo can detect out-of-contract usages."}],"servers":[{"url":"https://api.hiboo.io","description":"Production server"},{"url":"https://api-sandbox.hiboo.io","description":"Sandbox server"}],"security":[{"JWT":[]}],"components":{"securitySchemes":{"JWT":{"type":"apiKey","in":"header","name":"x-access-token","description":"Generate a JWT when you log in. Use it in your following requests in the header as `x-access-token: your-token-here`\n"}},"schemas":{"CreateContractAssignmentBody":{"required":["contractReference","assetId","startDate","endDate","customer","workingDays","country","currency"],"type":"object","properties":{"contractReference":{"description":"The reference of the contract the equipment is assigned to","type":"string","minLength":1},"assetId":{"description":"Hiboo's id of the equipment to assign to the contract","type":"integer","format":"int32"},"startDate":{"description":"First day of the contract assignment (YYYY-MM-DD), asset timezone","type":"string","format":"date"},"endDate":{"description":"Last day of the contract assignment (YYYY-MM-DD), asset timezone. Must not be before the start date","type":"string","format":"date"},"maximumHoursPerDay":{"description":"Maximum number of usage hours per day allowed by the contract, between 0 (exclusive) and 24. Set it to `null` or omit it if the contract does not limit the daily usage","type":"number","nullable":true,"exclusiveMinimum":true,"minimum":0,"maximum":24},"customer":{"description":"Name of the customer renting the equipment","type":"string","minLength":1},"workingDays":{"description":"Days of the week on which the equipment is expected to be used under the contract","type":"array","minItems":1,"items":{"type":"string","enum":["monday","tuesday","wednesday","thursday","friday","saturday","sunday"]}},"excludedDays":{"description":"Specific dates (YYYY-MM-DD) to exclude from the contract, even if they fall on a working day. A date cannot be both excluded and included","type":"array","items":{"type":"string","format":"date"}},"includedDays":{"description":"Specific dates (YYYY-MM-DD) to include in the contract, even if they do not fall on a working day. A date cannot be both excluded and included","type":"array","items":{"type":"string","format":"date"}},"excludePublicHolidays":{"description":"If true, public holidays of the specified country are excluded from the contract. Defaults to false","type":"boolean"},"country":{"description":"Country used to determine public holidays","type":"string","enum":["FR","GB"]},"dailyRate":{"description":"Daily rate charged for out-of-contract usage. Must be greater than or equal to 0. Set it to `null` or omit it if not defined","type":"number","nullable":true,"minimum":0},"currency":{"description":"Currency of the daily rate, as a 3-letter ISO 4217 code","type":"string","minLength":3,"maxLength":3}}},"ContractAssignment":{"required":["id","contractReference","assetId","startDate","endDate","maximumHoursPerDay","customer","workingDays","excludedDays","includedDays","excludePublicHolidays","country","dailyRate","currency"],"type":"object","properties":{"id":{"description":"Unique identifier of the contract assignment, generated by Hiboo","type":"integer","format":"int32"},"contractReference":{"description":"The reference of the contract the equipment is assigned to","type":"string"},"assetId":{"description":"Hiboo's id of the equipment assigned to the contract","type":"integer","format":"int32"},"startDate":{"description":"First day of the contract assignment (YYYY-MM-DD), asset timezone","type":"string","format":"date"},"endDate":{"description":"Last day of the contract assignment (YYYY-MM-DD), asset timezone. Must not be before the start date","type":"string","format":"date"},"maximumHoursPerDay":{"description":"Maximum number of usage hours per day allowed by the contract. `null` if the contract does not limit the daily usage","type":"number","nullable":true},"customer":{"description":"Name of the customer renting the equipment","type":"string"},"workingDays":{"description":"Days of the week on which the equipment is expected to be used under the contract","type":"array","minItems":1,"items":{"type":"string","enum":["monday","tuesday","wednesday","thursday","friday","saturday","sunday"]}},"excludedDays":{"description":"Specific dates (YYYY-MM-DD) excluded from the contract, even if they fall on a working day","type":"array","items":{"type":"string","format":"date"}},"includedDays":{"description":"Specific dates (YYYY-MM-DD) included in the contract, even if they do not fall on a working day","type":"array","items":{"type":"string","format":"date"}},"excludePublicHolidays":{"description":"If true, public holidays of the specified country are excluded from the contract","type":"boolean"},"country":{"description":"Country used to determine public holidays","type":"string","enum":["FR","GB"]},"dailyRate":{"description":"Daily rate charged for out-of-contract usage. `null` if not defined","type":"number","nullable":true},"currency":{"description":"Currency of the daily rate, as a 3-letter ISO 4217 code","type":"string","minLength":3,"maxLength":3}}},"Error":{"required":["message","details"],"type":"object","properties":{"message":{"type":"string","description":"A human readable description of the error"},"details":{"type":"object","description":"Additional information about the Error"}}},"NoDetailError":{"required":["message"],"type":"object","properties":{"message":{"type":"string","description":"A human readable description of the error"}}}},"responses":{"401Error":{"description":"Unable to authenticate the token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NoDetailError"}}}},"403Error":{"description":"Insufficient permissions to access the resource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NoDetailError"}}}}}},"paths":{"/v2/fleet/contracts/assignments":{"post":{"tags":["Contracts"],"summary":"Create a contract assignment","description":"Assigns an equipment to a contract for a given period. The contract assignment defines the expected usage of the equipment (working days, maximum hours per day), which is used to detect out-of-contract usage.","operationId":"createContractAssignment","requestBody":{"description":"The contract assignment to create","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateContractAssignmentBody"}}},"required":true},"responses":{"201":{"description":"Contract assignment successfully created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractAssignment"}}}},"400":{"description":"Missing parameters or invalid parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/401Error"},"403":{"$ref":"#/components/responses/403Error"},"404":{"description":"Equipment not found in your organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NoDetailError"}}}}}}}}}
```

## Update a contract assignment

> Replaces an existing contract assignment with the provided representation. All the fields must be provided; the contract reference and the equipment cannot be changed.

```json
{"openapi":"3.0.3","info":{"title":"Hiboo API","version":"2.0.0"},"tags":[{"name":"Contracts","description":"The following endpoints allow you to assign your equipments to contracts data, so that Hiboo can detect out-of-contract usages."}],"servers":[{"url":"https://api.hiboo.io","description":"Production server"},{"url":"https://api-sandbox.hiboo.io","description":"Sandbox server"}],"security":[{"JWT":[]}],"components":{"securitySchemes":{"JWT":{"type":"apiKey","in":"header","name":"x-access-token","description":"Generate a JWT when you log in. Use it in your following requests in the header as `x-access-token: your-token-here`\n"}},"schemas":{"EditContractAssignmentBody":{"required":["startDate","endDate","customer","workingDays","country","currency"],"type":"object","properties":{"startDate":{"description":"First day of the contract assignment (YYYY-MM-DD), asset timezone","type":"string","format":"date"},"endDate":{"description":"Last day of the contract assignment (YYYY-MM-DD), asset timezone. Must not be before the start date","type":"string","format":"date"},"maximumHoursPerDay":{"description":"Maximum number of usage hours per day allowed by the contract, between 0 (exclusive) and 24. Set it to `null` or omit it if the contract does not limit the daily usage","type":"number","nullable":true,"exclusiveMinimum":true,"minimum":0,"maximum":24},"customer":{"description":"Name of the customer renting the equipment","type":"string","minLength":1},"workingDays":{"description":"Days of the week on which the equipment is expected to be used under the contract","type":"array","minItems":1,"items":{"type":"string","enum":["monday","tuesday","wednesday","thursday","friday","saturday","sunday"]}},"excludedDays":{"description":"Specific dates (YYYY-MM-DD) to exclude from the contract, even if they fall on a working day. A date cannot be both excluded and included","type":"array","items":{"type":"string","format":"date"}},"includedDays":{"description":"Specific dates (YYYY-MM-DD) to include in the contract, even if they do not fall on a working day. A date cannot be both excluded and included","type":"array","items":{"type":"string","format":"date"}},"excludePublicHolidays":{"description":"If true, public holidays of the specified country are excluded from the contract. Defaults to false","type":"boolean"},"country":{"description":"Country used to determine public holidays","type":"string","enum":["FR","GB"]},"dailyRate":{"description":"Daily rate charged for out-of-contract usage. Must be greater than or equal to 0. Set it to `null` or omit it if not defined","type":"number","nullable":true,"minimum":0},"currency":{"description":"Currency of the daily rate, as a 3-letter ISO 4217 code","type":"string","minLength":3,"maxLength":3}}},"ContractAssignment":{"required":["id","contractReference","assetId","startDate","endDate","maximumHoursPerDay","customer","workingDays","excludedDays","includedDays","excludePublicHolidays","country","dailyRate","currency"],"type":"object","properties":{"id":{"description":"Unique identifier of the contract assignment, generated by Hiboo","type":"integer","format":"int32"},"contractReference":{"description":"The reference of the contract the equipment is assigned to","type":"string"},"assetId":{"description":"Hiboo's id of the equipment assigned to the contract","type":"integer","format":"int32"},"startDate":{"description":"First day of the contract assignment (YYYY-MM-DD), asset timezone","type":"string","format":"date"},"endDate":{"description":"Last day of the contract assignment (YYYY-MM-DD), asset timezone. Must not be before the start date","type":"string","format":"date"},"maximumHoursPerDay":{"description":"Maximum number of usage hours per day allowed by the contract. `null` if the contract does not limit the daily usage","type":"number","nullable":true},"customer":{"description":"Name of the customer renting the equipment","type":"string"},"workingDays":{"description":"Days of the week on which the equipment is expected to be used under the contract","type":"array","minItems":1,"items":{"type":"string","enum":["monday","tuesday","wednesday","thursday","friday","saturday","sunday"]}},"excludedDays":{"description":"Specific dates (YYYY-MM-DD) excluded from the contract, even if they fall on a working day","type":"array","items":{"type":"string","format":"date"}},"includedDays":{"description":"Specific dates (YYYY-MM-DD) included in the contract, even if they do not fall on a working day","type":"array","items":{"type":"string","format":"date"}},"excludePublicHolidays":{"description":"If true, public holidays of the specified country are excluded from the contract","type":"boolean"},"country":{"description":"Country used to determine public holidays","type":"string","enum":["FR","GB"]},"dailyRate":{"description":"Daily rate charged for out-of-contract usage. `null` if not defined","type":"number","nullable":true},"currency":{"description":"Currency of the daily rate, as a 3-letter ISO 4217 code","type":"string","minLength":3,"maxLength":3}}},"Error":{"required":["message","details"],"type":"object","properties":{"message":{"type":"string","description":"A human readable description of the error"},"details":{"type":"object","description":"Additional information about the Error"}}},"NoDetailError":{"required":["message"],"type":"object","properties":{"message":{"type":"string","description":"A human readable description of the error"}}}},"responses":{"401Error":{"description":"Unable to authenticate the token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NoDetailError"}}}},"403Error":{"description":"Insufficient permissions to access the resource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NoDetailError"}}}}}},"paths":{"/v2/fleet/contracts/assignments/{id}":{"put":{"tags":["Contracts"],"summary":"Update a contract assignment","description":"Replaces an existing contract assignment with the provided representation. All the fields must be provided; the contract reference and the equipment cannot be changed.","operationId":"editContractAssignment","parameters":[{"name":"id","in":"path","description":"The id of the contract assignment, returned when it was created","required":true,"schema":{"type":"integer","format":"int32"}}],"requestBody":{"description":"The new values of the contract assignment","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EditContractAssignmentBody"}}},"required":true},"responses":{"200":{"description":"Contract assignment successfully updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractAssignment"}}}},"400":{"description":"Missing parameters or invalid parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/401Error"},"403":{"$ref":"#/components/responses/403Error"},"404":{"description":"Contract assignment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NoDetailError"}}}}}}}}}
```
