# Custom Instance

## Retrieving all custom instances

> Retrieves all custom instances associated with a specific custom schema type.

```json
{"openapi":"3.0.1","info":{"title":"Schema Service","version":"0.0.1"},"tags":[{"name":"Custom Instance"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["schema.custominstance_read","custom.{lowerCaseType}_read","custom.{lowerCaseType}_read_own"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"schema.schema_manage":"Required for managing schemas.","schema.schema_read":"Required for reading schemas.","schema.custominstance_read":"Read custom instances of any custom schema type.","schema.custominstance_manage":"Manage custom instances of any custom schema type.","custom.{lowerCaseType}_manage":"Manage custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage`.","custom.{lowerCaseType}_manage_own":"Allows to manage only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage_own`.","custom.{lowerCaseType}_read":"Read custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read`.","custom.{lowerCaseType}_read_own":"Allows to read only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read_own`."}}}}},"schemas":{"CustomInstancesResponse":{"type":"array","items":{"$ref":"#/components/schemas/CustomInstanceResponse"}},"CustomInstanceResponse":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of the custom instance."},"name":{"type":"object","description":"Localized custom type name in a form of a map of translations."},"type":{"type":"string","description":"Custom schema type to which custom instance is related."},"owner":{"readOnly":true,"allOf":[{"$ref":"#/components/schemas/CustomInstanceOwner"}]},"mixins":{"type":"string","description":"A key-value map of additional attributes."},"media":{"type":"array","description":"List of media IDs assigned to the custom instance.","items":{"type":"string"}},"metadata":{"allOf":[{"$ref":"#/components/schemas/CustomInstanceMetadata"}]}}},"CustomInstanceOwner":{"type":"object","description":"Ownership of the custom instance, which is populated automatically based on who created the custom instance.\nThe `legalEntityId` field is only present when `type` is `CUSTOMER`.\n","properties":{"type":{"type":"string","enum":["EMPLOYEE","CUSTOMER","SERVICE"]},"userId":{"type":"string","description":"Identifier of the employee, customer, or service principal associated with the owner."},"legalEntityId":{"type":"string","nullable":true,"description":"Legal entity identifier. Only set when `type` is `CUSTOMER`."}},"required":["type","userId"]},"CustomInstanceMetadata":{"type":"object","properties":{"createdAt":{"type":"string","description":"Date and time when the object was created, compliant with the ISO 8601 standard. For example: `2022-03-31T09:52:15.423Z`"},"modifiedAt":{"type":"string","description":"Date and time when the object was last modified, compliant with the ISO 8601 standard. For example: `2022-03-31T09:52:15.423Z`"},"version":{"type":"integer","description":"Version of the custom instance."},"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema."}}},"ErrorResponse":{"required":["code","message","status"],"type":"object","properties":{"id":{"type":"string","nullable":true},"code":{"type":"integer","format":"int32"},"status":{"type":"string"},"message":{"type":"string"},"errorCode":{"type":"string","nullable":true},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}},"responses":{"Bad_request_400":{"description":"Unsupported language provided.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer"},"status":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}}}},"Unauthorized_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired. It usually means that the tenant from the token does not match tenant from path.","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Forbidden_403":{"description":"Permission denied due to insufficient rights. This may happen when the request does not contain sufficient scopes for the given query values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"parameters":{"trail_xTotalCount_header":{"name":"X-Total-Count","in":"header","required":false,"schema":{"type":"boolean","default":false},"description":"Flag indicating whether the total number of retrieved items should be returned.\n"},"trait_paged_pageNumber":{"name":"pageNumber","in":"query","description":"Page number to be retrieved. The number of the first page is 1.\n","schema":{"default":1,"minimum":1,"type":"integer"}},"trait_paged_pageSize":{"name":"pageSize","in":"query","description":"Number of items to be retrieved per page.\n","schema":{"default":60,"minimum":1,"type":"integer"}},"trait_sort":{"name":"sort","in":"query","description":"List of properties used to sort the results, separated by colons. The order of properties indicates their priority in sorting.\n\nPossible values:\n* `{fieldName}`\n* `{fieldName}:asc`\n* `{fieldName}:desc`\n\n**Note:** If you want to sort the results by localized properties, the possible values are:\n  * `{fieldName}.{language}`\n  * `{fieldName}.{language}:asc`\n  * `{fieldName}.{language}:desc`\n\nIf the sorting direction is not specified, the fields are sorted in ascending order.","schema":{"type":"string"}},"trait_q_param":{"name":"q","in":"query","description":"A standard query parameter is used to search for specific values.\n\n* Searching for items by string-based properties:\n  * By a field value: `q=siteCode:main`, where `siteCode` is the field name, and `main` is its desired value.\n  * By a localized field value: `q=items.product.name.en:apple_lobo`, where `name` is the field name of product, `en` is the language code, and `apple_lobo` is the field value expressed in the specified language. **Note**: This query works only for localized fields, which are stored in a map format, where `key` is the language code and `value` is the translation to particular language.\n* Searching for items by a number-based property:\n  * With a specific value: `q=items.quantity.quantity:20`\n  * With a value greater than: `q=items.quantity.quantity:>20`\n  * With a value lower than: `q=items.quantity.quantity:<20`\n  * With a value greater than or equal to: `q=items.quantity.quantity:>=20`\n  * With a value lower than or equal to: `q=items.quantity.quantity:<=20`\n  * With a value within a range of values: `q=items.quantity.quantity:(>=10 AND <=20)`\\\n   where `items.quantity.quantity` is the name of the number-based field, and `20` is its querying value.\n* Searching for items by a date-based property: All number-based property queries are also valid for dates. In that case, the date should be placed within double quotes: `q=metadataCreatedAt:(>=\"2021-05-18T07:27:27.455Z\" AND <\"2021-05-20T07:27:27.455Z\")`\n* Searching for items by a boolean-based property: `q=description.multiLanguage:true`, where `description.multiLanguage` is the boolean field name, and `true` is its desired value.\n* Searching for items with a nonexistent or empty property: `q=description.en:null`, where `description.en` is the field that has its value set to `null`.\n* Searching for items with an existing property: `q=mixins.mixinName:exists`, where the specific mixin named `mixinName` exists in the database.\n* Searching for items by multiple specific values: `q=id:(5c3325baa9812100098ff48f,5c3325d1a9812100098ff494)`, where `id` is the field name, and strings within the bracket are the desired values.\n* Searching for items by multiple fields: `q=id:5c3325baa9812100098ff48f siteCode:main` where `id` and `siteCode` are field names. All objects that contain the specified values are returned. Multiple fields (separated by space) can be specified. Multiple values for each field can also be specified in the format presented earlier.\n* Searching for items with string-based properties conforming to a regex: `q=siteCode:~ain` or `q=code:(~U PL)` - in case of searching for strings with space, where `siteCode` is the name of the field, and `ain` or `U PL` is its querying regex.\n* Searching for items with a localized string-based property conforming to a regex: `items.product.name.en:~(Yoghurt im)` - where `name` is the product field name, `en` is the desired language, and `Joghurt im` is the search term.\n","schema":{"type":"string"}},"trait_fields":{"name":"fields","in":"query","description":"Fields to be included in the response.\n","schema":{"type":"string"}},"trait_acceptLanguage_header":{"name":"Accept-Language","in":"header","required":false,"schema":{"type":"string"},"description":"List of language codes acceptable for the response. You can specify factors that indicate which language should be retrieved if the one with a higher factor was not found in the localized fields. If a value is specified, then it must be present in the tenant configuration.\n* If the header is set to a particular language or a list of languages, all localized fields are retrieved as strings.\n* If the header is set to `*`, all localized fields are retrieved as maps of translations, where the keys are language codes and values are the fields in their respective languages.\n* If the header is empty, localized fields are retrieved in the default language defined in the Configuration Service.\n"},"trait_expand_references":{"name":"expand","in":"query","required":false,"schema":{"type":"string"},"description":"Fetches data about expanded references. You can provide full path to the reference, use wildcard character `*`, or provide a specific index (starting with 0) in array of references. Multiple paths can be specified by separating them with commas.\n\n**Examples:**\n* `customAttributes.references.product_reference` - expands a specific reference\n* `*` - expands all references\n* `customAttributes.*` - expands all references within customAttributes\n* `customAttributes.references.customers_array.0` - expands the first element in an array of references\n"}}},"paths":{"/schema/{tenant}/custom-entities/{type}/instances":{"get":{"summary":"Retrieving all custom instances","description":"Retrieves all custom instances associated with a specific custom schema type.","tags":["Custom Instance"],"responses":{"200":{"description":"","headers":{"X-Total-Count":{"description":"Total amount of custom instances for given criteria.","schema":{"type":"integer","format":"int32"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomInstancesResponse"}}}},"400":{"$ref":"#/components/responses/Bad_request_400"},"401":{"$ref":"#/components/responses/Unauthorized_401"},"403":{"$ref":"#/components/responses/Forbidden_403"}},"operationId":"GET-schema-retrieve-custom-instances","parameters":[{"$ref":"#/components/parameters/trail_xTotalCount_header"},{"$ref":"#/components/parameters/trait_paged_pageNumber"},{"$ref":"#/components/parameters/trait_paged_pageSize"},{"$ref":"#/components/parameters/trait_sort"},{"$ref":"#/components/parameters/trait_q_param"},{"$ref":"#/components/parameters/trait_fields"},{"$ref":"#/components/parameters/trait_acceptLanguage_header"},{"$ref":"#/components/parameters/trait_expand_references"}]}}}}
```

## Creating a custom instance

> Creates a custom instance entity associated with given custom schema type.<br>

```json
{"openapi":"3.0.1","info":{"title":"Schema Service","version":"0.0.1"},"tags":[{"name":"Custom Instance"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["schema.custominstance_manage","custom.{lowerCaseType}_manage","custom.{lowerCaseType}_manage_own"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"schema.schema_manage":"Required for managing schemas.","schema.schema_read":"Required for reading schemas.","schema.custominstance_read":"Read custom instances of any custom schema type.","schema.custominstance_manage":"Manage custom instances of any custom schema type.","custom.{lowerCaseType}_manage":"Manage custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage`.","custom.{lowerCaseType}_manage_own":"Allows to manage only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage_own`.","custom.{lowerCaseType}_read":"Read custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read`.","custom.{lowerCaseType}_read_own":"Allows to read only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read_own`."}}}}},"parameters":{"trait_contentLanguage_header":{"in":"header","name":"Content-Language","description":"The Content-Language request HTTP header defines language(s) of the payload.","schema":{"type":"string"}},"trait_validateReferences":{"name":"validateReferences","in":"query","required":false,"schema":{"type":"boolean","default":true},"description":"When set to true, references are validated if the provided resources exist. If set to false, validation is skipped.\n"}},"schemas":{"CustomInstanceCreation":{"type":"object","properties":{"id":{"type":"string","description":"Id of the custom instance."},"name":{"type":"object","description":"Localized custom type name in a form of a map of translations."},"mixins":{"type":"string","description":"A key-value map of additional attributes."},"metadata":{"type":"object","properties":{"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema."}}}}},"IdResponse":{"type":"object","properties":{"id":{"type":"string","description":"ID of the generated document."}},"description":"Id of the created schema."},"ErrorResponse":{"required":["code","message","status"],"type":"object","properties":{"id":{"type":"string","nullable":true},"code":{"type":"integer","format":"int32"},"status":{"type":"string"},"message":{"type":"string"},"errorCode":{"type":"string","nullable":true},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}},"responses":{"Bad_request_400_mixins":{"description":"Mixins validation failed.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer"},"status":{"type":"string"},"message":{"type":"string"},"errorCode":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}}}},"Unauthorized_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired. It usually means that the tenant from the token does not match tenant from path.","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Conflict_409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/schema/{tenant}/custom-entities/{type}/instances":{"post":{"tags":["Custom Instance"],"summary":"Creating a custom instance","parameters":[{"$ref":"#/components/parameters/trait_contentLanguage_header"},{"$ref":"#/components/parameters/trait_validateReferences"}],"description":"Creates a custom instance entity associated with given custom schema type.\n","operationId":"POST-schema-create-custom-instance","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomInstanceCreation"}}}},"responses":{"201":{"description":"Custom instance was successfully created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdResponse"}}}},"400":{"$ref":"#/components/responses/Bad_request_400_mixins"},"401":{"$ref":"#/components/responses/Unauthorized_401"},"403":{"description":"Permission denied due to insufficient rights. This may happen when the request does not contain sufficient scopes for the given query values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"$ref":"#/components/responses/Conflict_409"}}}}}}
```

## Retrieving a custom instance

> Retrieves a single custom instance by id.

```json
{"openapi":"3.0.1","info":{"title":"Schema Service","version":"0.0.1"},"tags":[{"name":"Custom Instance"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["schema.custominstance_read","custom.{lowerCaseType}_read","custom.{lowerCaseType}_read_own"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"schema.schema_manage":"Required for managing schemas.","schema.schema_read":"Required for reading schemas.","schema.custominstance_read":"Read custom instances of any custom schema type.","schema.custominstance_manage":"Manage custom instances of any custom schema type.","custom.{lowerCaseType}_manage":"Manage custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage`.","custom.{lowerCaseType}_manage_own":"Allows to manage only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage_own`.","custom.{lowerCaseType}_read":"Read custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read`.","custom.{lowerCaseType}_read_own":"Allows to read only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read_own`."}}}}},"parameters":{"trait_acceptLanguage_header":{"name":"Accept-Language","in":"header","required":false,"schema":{"type":"string"},"description":"List of language codes acceptable for the response. You can specify factors that indicate which language should be retrieved if the one with a higher factor was not found in the localized fields. If a value is specified, then it must be present in the tenant configuration.\n* If the header is set to a particular language or a list of languages, all localized fields are retrieved as strings.\n* If the header is set to `*`, all localized fields are retrieved as maps of translations, where the keys are language codes and values are the fields in their respective languages.\n* If the header is empty, localized fields are retrieved in the default language defined in the Configuration Service.\n"},"trait_expand_references":{"name":"expand","in":"query","required":false,"schema":{"type":"string"},"description":"Fetches data about expanded references. You can provide full path to the reference, use wildcard character `*`, or provide a specific index (starting with 0) in array of references. Multiple paths can be specified by separating them with commas.\n\n**Examples:**\n* `customAttributes.references.product_reference` - expands a specific reference\n* `*` - expands all references\n* `customAttributes.*` - expands all references within customAttributes\n* `customAttributes.references.customers_array.0` - expands the first element in an array of references\n"}},"schemas":{"CustomInstanceResponse":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of the custom instance."},"name":{"type":"object","description":"Localized custom type name in a form of a map of translations."},"type":{"type":"string","description":"Custom schema type to which custom instance is related."},"owner":{"readOnly":true,"allOf":[{"$ref":"#/components/schemas/CustomInstanceOwner"}]},"mixins":{"type":"string","description":"A key-value map of additional attributes."},"media":{"type":"array","description":"List of media IDs assigned to the custom instance.","items":{"type":"string"}},"metadata":{"allOf":[{"$ref":"#/components/schemas/CustomInstanceMetadata"}]}}},"CustomInstanceOwner":{"type":"object","description":"Ownership of the custom instance, which is populated automatically based on who created the custom instance.\nThe `legalEntityId` field is only present when `type` is `CUSTOMER`.\n","properties":{"type":{"type":"string","enum":["EMPLOYEE","CUSTOMER","SERVICE"]},"userId":{"type":"string","description":"Identifier of the employee, customer, or service principal associated with the owner."},"legalEntityId":{"type":"string","nullable":true,"description":"Legal entity identifier. Only set when `type` is `CUSTOMER`."}},"required":["type","userId"]},"CustomInstanceMetadata":{"type":"object","properties":{"createdAt":{"type":"string","description":"Date and time when the object was created, compliant with the ISO 8601 standard. For example: `2022-03-31T09:52:15.423Z`"},"modifiedAt":{"type":"string","description":"Date and time when the object was last modified, compliant with the ISO 8601 standard. For example: `2022-03-31T09:52:15.423Z`"},"version":{"type":"integer","description":"Version of the custom instance."},"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema."}}},"ErrorResponse":{"required":["code","message","status"],"type":"object","properties":{"id":{"type":"string","nullable":true},"code":{"type":"integer","format":"int32"},"status":{"type":"string"},"message":{"type":"string"},"errorCode":{"type":"string","nullable":true},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}},"responses":{"Unauthorized_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired. It usually means that the tenant from the token does not match tenant from path.","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Forbidden_403":{"description":"Permission denied due to insufficient rights. This may happen when the request does not contain sufficient scopes for the given query values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Not_Found_404":{"description":"Given resource cannot be found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/schema/{tenant}/custom-entities/{type}/instances/{id}":{"get":{"summary":"Retrieving a custom instance","parameters":[{"$ref":"#/components/parameters/trait_acceptLanguage_header"},{"$ref":"#/components/parameters/trait_expand_references"}],"description":"Retrieves a single custom instance by id.","tags":["Custom Instance"],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomInstanceResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized_401"},"403":{"$ref":"#/components/responses/Forbidden_403"},"404":{"$ref":"#/components/responses/Not_Found_404"}},"operationId":"GET-schema-retrieve-custom-instance"}}}}
```

## Upserting a custom instance

> Performs the \`UPSERT\` operation. If a custom instance with specified ID exists in the system, then it is updated. If it doesn't exist, a new custom instance is created.

```json
{"openapi":"3.0.1","info":{"title":"Schema Service","version":"0.0.1"},"tags":[{"name":"Custom Instance"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["schema.custominstance_manage","custom.{lowerCaseType}_manage","custom.{lowerCaseType}_manage_own"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"schema.schema_manage":"Required for managing schemas.","schema.schema_read":"Required for reading schemas.","schema.custominstance_read":"Read custom instances of any custom schema type.","schema.custominstance_manage":"Manage custom instances of any custom schema type.","custom.{lowerCaseType}_manage":"Manage custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage`.","custom.{lowerCaseType}_manage_own":"Allows to manage only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage_own`.","custom.{lowerCaseType}_read":"Read custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read`.","custom.{lowerCaseType}_read_own":"Allows to read only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read_own`."}}}}},"parameters":{"trait_contentLanguage_header":{"in":"header","name":"Content-Language","description":"The Content-Language request HTTP header defines language(s) of the payload.","schema":{"type":"string"}},"trait_validateReferences":{"name":"validateReferences","in":"query","required":false,"schema":{"type":"boolean","default":true},"description":"When set to true, references are validated if the provided resources exist. If set to false, validation is skipped.\n"}},"schemas":{"CustomInstanceUpdate":{"type":"object","properties":{"name":{"type":"object","description":"Localized custom type name in a form of a map of translations."},"mixins":{"type":"string","description":"A key-value map of additional attributes."},"metadata":{"type":"object","properties":{"version":{"type":"integer","description":"Version of the custom instance.  If provided, it will be validated against the current entity version."},"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema."}}}}},"IdResponse":{"type":"object","properties":{"id":{"type":"string","description":"ID of the generated document."}},"description":"Id of the created schema."},"ErrorResponse":{"required":["code","message","status"],"type":"object","properties":{"id":{"type":"string","nullable":true},"code":{"type":"integer","format":"int32"},"status":{"type":"string"},"message":{"type":"string"},"errorCode":{"type":"string","nullable":true},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}},"responses":{"Bad_request_400_mixins":{"description":"Mixins validation failed.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer"},"status":{"type":"string"},"message":{"type":"string"},"errorCode":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}}}},"Unauthorized_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired. It usually means that the tenant from the token does not match tenant from path.","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Forbidden_403":{"description":"Permission denied due to insufficient rights. This may happen when the request does not contain sufficient scopes for the given query values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/schema/{tenant}/custom-entities/{type}/instances/{id}":{"put":{"summary":"Upserting a custom instance","parameters":[{"$ref":"#/components/parameters/trait_contentLanguage_header"},{"$ref":"#/components/parameters/trait_validateReferences"}],"description":"Performs the `UPSERT` operation. If a custom instance with specified ID exists in the system, then it is updated. If it doesn't exist, a new custom instance is created.","tags":["Custom Instance"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomInstanceUpdate"}}},"description":""},"responses":{"201":{"description":"Custom instance was successfully created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdResponse"}}}},"204":{"description":"Custom instance was successfully updated"},"400":{"$ref":"#/components/responses/Bad_request_400_mixins"},"401":{"$ref":"#/components/responses/Unauthorized_401"},"403":{"$ref":"#/components/responses/Forbidden_403"},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"operationId":"PUT-schema-upsert-custom-instance"}}}}
```

## Deleting a custom instance

> Deletes a custom instance.

```json
{"openapi":"3.0.1","info":{"title":"Schema Service","version":"0.0.1"},"tags":[{"name":"Custom Instance"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["schema.custominstance_manage","custom.{lowerCaseType}_manage","custom.{lowerCaseType}_manage_own"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"schema.schema_manage":"Required for managing schemas.","schema.schema_read":"Required for reading schemas.","schema.custominstance_read":"Read custom instances of any custom schema type.","schema.custominstance_manage":"Manage custom instances of any custom schema type.","custom.{lowerCaseType}_manage":"Manage custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage`.","custom.{lowerCaseType}_manage_own":"Allows to manage only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage_own`.","custom.{lowerCaseType}_read":"Read custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read`.","custom.{lowerCaseType}_read_own":"Allows to read only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read_own`."}}}}},"responses":{"Unauthorized_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired. It usually means that the tenant from the token does not match tenant from path.","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Forbidden_403":{"description":"Permission denied due to insufficient rights. This may happen when the request does not contain sufficient scopes for the given query values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"schemas":{"ErrorResponse":{"required":["code","message","status"],"type":"object","properties":{"id":{"type":"string","nullable":true},"code":{"type":"integer","format":"int32"},"status":{"type":"string"},"message":{"type":"string"},"errorCode":{"type":"string","nullable":true},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}}},"paths":{"/schema/{tenant}/custom-entities/{type}/instances/{id}":{"delete":{"summary":"Deleting a custom instance","description":"Deletes a custom instance.","tags":["Custom Instance"],"responses":{"204":{"description":"No content"},"401":{"$ref":"#/components/responses/Unauthorized_401"},"403":{"$ref":"#/components/responses/Forbidden_403"}},"operationId":"DELETE-schema-remove-custom-instance"}}}}
```

## Patching a custom instance

> The patch request consists of set of operation, that should be defined according to \[RFC-6902]\(<https://datatracker.ietf.org/doc/html/rfc6902>) standard.

```json
{"openapi":"3.0.1","info":{"title":"Schema Service","version":"0.0.1"},"tags":[{"name":"Custom Instance"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["schema.custominstance_manage","custom.{lowerCaseType}_manage","custom.{lowerCaseType}_manage_own"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"schema.schema_manage":"Required for managing schemas.","schema.schema_read":"Required for reading schemas.","schema.custominstance_read":"Read custom instances of any custom schema type.","schema.custominstance_manage":"Manage custom instances of any custom schema type.","custom.{lowerCaseType}_manage":"Manage custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage`.","custom.{lowerCaseType}_manage_own":"Allows to manage only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage_own`.","custom.{lowerCaseType}_read":"Read custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read`.","custom.{lowerCaseType}_read_own":"Allows to read only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read_own`."}}}}},"parameters":{"trait_contentLanguage_header":{"in":"header","name":"Content-Language","description":"The Content-Language request HTTP header defines language(s) of the payload.","schema":{"type":"string"}},"trait_validateReferences":{"name":"validateReferences","in":"query","required":false,"schema":{"type":"boolean","default":true},"description":"When set to true, references are validated if the provided resources exist. If set to false, validation is skipped.\n"}},"schemas":{"PatchOperation":{"type":"object","properties":{"op":{"type":"string","enum":["add","remove","replace"],"description":"Indicates an operation which should be done on a return. Available operations: `add` `remove` and `replace`"},"path":{"type":"string","description":"Indicates a path for which the value should be applied. For example:`/mixins/additionalAttributes/externalId` or `/name`"},"value":{"oneOf":[{"type":"object"},{"type":"string"},{"type":"number"}],"description":"Indicates a value that should be changed or added. The value can be of a primitive type, like string, number, boolean or it can be an object or an array."}},"required":["op","path"]},"ErrorResponse":{"required":["code","message","status"],"type":"object","properties":{"id":{"type":"string","nullable":true},"code":{"type":"integer","format":"int32"},"status":{"type":"string"},"message":{"type":"string"},"errorCode":{"type":"string","nullable":true},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}},"responses":{"Bad_request_400_mixins":{"description":"Mixins validation failed.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer"},"status":{"type":"string"},"message":{"type":"string"},"errorCode":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}}}},"Unauthorized_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired. It usually means that the tenant from the token does not match tenant from path.","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Forbidden_403":{"description":"Permission denied due to insufficient rights. This may happen when the request does not contain sufficient scopes for the given query values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Not_Found_404":{"description":"Given resource cannot be found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/schema/{tenant}/custom-entities/{type}/instances/{id}":{"patch":{"summary":"Patching a custom instance","parameters":[{"$ref":"#/components/parameters/trait_contentLanguage_header"},{"$ref":"#/components/parameters/trait_validateReferences"}],"description":"The patch request consists of set of operation, that should be defined according to [RFC-6902](https://datatracker.ietf.org/doc/html/rfc6902) standard.","tags":["Custom Instance"],"requestBody":{"content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PatchOperation"}}}},"description":""},"responses":{"204":{"description":"Custom instance was successfully patched"},"400":{"$ref":"#/components/responses/Bad_request_400_mixins"},"401":{"$ref":"#/components/responses/Unauthorized_401"},"403":{"$ref":"#/components/responses/Forbidden_403"},"404":{"$ref":"#/components/responses/Not_Found_404"}},"operationId":"PATCH-schema-patch-custom-instance"}}}}
```

## Searching for custom instances

> Returns all custom instances for provided type that match specified criteria.

```json
{"openapi":"3.0.1","info":{"title":"Schema Service","version":"0.0.1"},"tags":[{"name":"Custom Instance"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["schema.custominstance_read","custom.{lowerCaseType}_read","custom.{lowerCaseType}_read_own"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"schema.schema_manage":"Required for managing schemas.","schema.schema_read":"Required for reading schemas.","schema.custominstance_read":"Read custom instances of any custom schema type.","schema.custominstance_manage":"Manage custom instances of any custom schema type.","custom.{lowerCaseType}_manage":"Manage custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage`.","custom.{lowerCaseType}_manage_own":"Allows to manage only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage_own`.","custom.{lowerCaseType}_read":"Read custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read`.","custom.{lowerCaseType}_read_own":"Allows to read only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read_own`."}}}}},"schemas":{"CustomInstancesResponse":{"type":"array","items":{"$ref":"#/components/schemas/CustomInstanceResponse"}},"CustomInstanceResponse":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of the custom instance."},"name":{"type":"object","description":"Localized custom type name in a form of a map of translations."},"type":{"type":"string","description":"Custom schema type to which custom instance is related."},"owner":{"readOnly":true,"allOf":[{"$ref":"#/components/schemas/CustomInstanceOwner"}]},"mixins":{"type":"string","description":"A key-value map of additional attributes."},"media":{"type":"array","description":"List of media IDs assigned to the custom instance.","items":{"type":"string"}},"metadata":{"allOf":[{"$ref":"#/components/schemas/CustomInstanceMetadata"}]}}},"CustomInstanceOwner":{"type":"object","description":"Ownership of the custom instance, which is populated automatically based on who created the custom instance.\nThe `legalEntityId` field is only present when `type` is `CUSTOMER`.\n","properties":{"type":{"type":"string","enum":["EMPLOYEE","CUSTOMER","SERVICE"]},"userId":{"type":"string","description":"Identifier of the employee, customer, or service principal associated with the owner."},"legalEntityId":{"type":"string","nullable":true,"description":"Legal entity identifier. Only set when `type` is `CUSTOMER`."}},"required":["type","userId"]},"CustomInstanceMetadata":{"type":"object","properties":{"createdAt":{"type":"string","description":"Date and time when the object was created, compliant with the ISO 8601 standard. For example: `2022-03-31T09:52:15.423Z`"},"modifiedAt":{"type":"string","description":"Date and time when the object was last modified, compliant with the ISO 8601 standard. For example: `2022-03-31T09:52:15.423Z`"},"version":{"type":"integer","description":"Version of the custom instance."},"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema."}}},"ErrorResponse":{"required":["code","message","status"],"type":"object","properties":{"id":{"type":"string","nullable":true},"code":{"type":"integer","format":"int32"},"status":{"type":"string"},"message":{"type":"string"},"errorCode":{"type":"string","nullable":true},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}},"responses":{"Unauthorized_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired. It usually means that the tenant from the token does not match tenant from path.","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Forbidden_403":{"description":"Permission denied due to insufficient rights. This may happen when the request does not contain sufficient scopes for the given query values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"parameters":{"trail_xTotalCount_header":{"name":"X-Total-Count","in":"header","required":false,"schema":{"type":"boolean","default":false},"description":"Flag indicating whether the total number of retrieved items should be returned.\n"},"trait_paged_pageNumber":{"name":"pageNumber","in":"query","description":"Page number to be retrieved. The number of the first page is 1.\n","schema":{"default":1,"minimum":1,"type":"integer"}},"trait_paged_pageSize":{"name":"pageSize","in":"query","description":"Number of items to be retrieved per page.\n","schema":{"default":60,"minimum":1,"type":"integer"}},"trait_sort":{"name":"sort","in":"query","description":"List of properties used to sort the results, separated by colons. The order of properties indicates their priority in sorting.\n\nPossible values:\n* `{fieldName}`\n* `{fieldName}:asc`\n* `{fieldName}:desc`\n\n**Note:** If you want to sort the results by localized properties, the possible values are:\n  * `{fieldName}.{language}`\n  * `{fieldName}.{language}:asc`\n  * `{fieldName}.{language}:desc`\n\nIf the sorting direction is not specified, the fields are sorted in ascending order.","schema":{"type":"string"}},"trait_acceptLanguage_header":{"name":"Accept-Language","in":"header","required":false,"schema":{"type":"string"},"description":"List of language codes acceptable for the response. You can specify factors that indicate which language should be retrieved if the one with a higher factor was not found in the localized fields. If a value is specified, then it must be present in the tenant configuration.\n* If the header is set to a particular language or a list of languages, all localized fields are retrieved as strings.\n* If the header is set to `*`, all localized fields are retrieved as maps of translations, where the keys are language codes and values are the fields in their respective languages.\n* If the header is empty, localized fields are retrieved in the default language defined in the Configuration Service.\n"},"trait_fields":{"name":"fields","in":"query","description":"Fields to be included in the response.\n","schema":{"type":"string"}},"trait_expand_references":{"name":"expand","in":"query","required":false,"schema":{"type":"string"},"description":"Fetches data about expanded references. You can provide full path to the reference, use wildcard character `*`, or provide a specific index (starting with 0) in array of references. Multiple paths can be specified by separating them with commas.\n\n**Examples:**\n* `customAttributes.references.product_reference` - expands a specific reference\n* `*` - expands all references\n* `customAttributes.*` - expands all references within customAttributes\n* `customAttributes.references.customers_array.0` - expands the first element in an array of references\n"}}},"paths":{"/schema/{tenant}/custom-entities/{type}/instances/search":{"post":{"summary":"Searching for custom instances","description":"Returns all custom instances for provided type that match specified criteria.","tags":["Custom Instance"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"q":{"type":"string","description":"A standard query parameter used to search for specific values."}}}}}},"responses":{"200":{"description":"Custom instances succesfully retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomInstancesResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized_401"},"403":{"$ref":"#/components/responses/Forbidden_403"}},"operationId":"POST-schema-search-custom-instances","parameters":[{"$ref":"#/components/parameters/trail_xTotalCount_header"},{"$ref":"#/components/parameters/trait_paged_pageNumber"},{"$ref":"#/components/parameters/trait_paged_pageSize"},{"$ref":"#/components/parameters/trait_sort"},{"$ref":"#/components/parameters/trait_acceptLanguage_header"},{"$ref":"#/components/parameters/trait_fields"},{"$ref":"#/components/parameters/trait_expand_references"}]}}}}
```

## Creating custom instances in bulk

> Creates multiple custom instances. The maximum batch size is 200.

```json
{"openapi":"3.0.1","info":{"title":"Schema Service","version":"0.0.1"},"tags":[{"name":"Custom Instance"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["schema.custominstance_manage","custom.{lowerCaseType}_manage","custom.{lowerCaseType}_manage_own"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"schema.schema_manage":"Required for managing schemas.","schema.schema_read":"Required for reading schemas.","schema.custominstance_read":"Read custom instances of any custom schema type.","schema.custominstance_manage":"Manage custom instances of any custom schema type.","custom.{lowerCaseType}_manage":"Manage custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage`.","custom.{lowerCaseType}_manage_own":"Allows to manage only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage_own`.","custom.{lowerCaseType}_read":"Read custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read`.","custom.{lowerCaseType}_read_own":"Allows to read only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read_own`."}}}}},"parameters":{"trait_validateReferences_bulk":{"name":"validateReferences","in":"query","required":false,"schema":{"type":"boolean","default":false},"description":"When set to true, references are validated if the provided resources exist. If set to false, validation is skipped.\n"}},"schemas":{"CustomInstanceCreation":{"type":"object","properties":{"id":{"type":"string","description":"Id of the custom instance."},"name":{"type":"object","description":"Localized custom type name in a form of a map of translations."},"mixins":{"type":"string","description":"A key-value map of additional attributes."},"metadata":{"type":"object","properties":{"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema."}}}}},"BulkResponse":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer","description":"Index of the processed item, matching the item position in request body."},"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status description"},"message":{"type":"string","description":"Error message."},"details":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string","description":"Error details."}}}}}}},"ErrorResponse":{"required":["code","message","status"],"type":"object","properties":{"id":{"type":"string","nullable":true},"code":{"type":"integer","format":"int32"},"status":{"type":"string"},"message":{"type":"string"},"errorCode":{"type":"string","nullable":true},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}},"responses":{"Unauthorized_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired. It usually means that the tenant from the token does not match tenant from path.","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Forbidden_403":{"description":"Permission denied due to insufficient rights. This may happen when the request does not contain sufficient scopes for the given query values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/schema/{tenant}/custom-entities/{type}/instances/bulk":{"post":{"summary":"Creating custom instances in bulk","description":"Creates multiple custom instances. The maximum batch size is 200.","tags":["Custom Instance"],"parameters":[{"$ref":"#/components/parameters/trait_validateReferences_bulk"}],"requestBody":{"content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CustomInstanceCreation"}}}}},"responses":{"207":{"description":"Bulk operation was successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized_401"},"403":{"$ref":"#/components/responses/Forbidden_403"}},"operationId":"POST-schema-create-custom-instances-bulk"}}}}
```

## Upserting custom instances in bulk

> Upserts multiple custom instances. The maximum batch size is 200.

```json
{"openapi":"3.0.1","info":{"title":"Schema Service","version":"0.0.1"},"tags":[{"name":"Custom Instance"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["schema.custominstance_manage","custom.{lowerCaseType}_manage","custom.{lowerCaseType}_manage_own"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"schema.schema_manage":"Required for managing schemas.","schema.schema_read":"Required for reading schemas.","schema.custominstance_read":"Read custom instances of any custom schema type.","schema.custominstance_manage":"Manage custom instances of any custom schema type.","custom.{lowerCaseType}_manage":"Manage custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage`.","custom.{lowerCaseType}_manage_own":"Allows to manage only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage_own`.","custom.{lowerCaseType}_read":"Read custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read`.","custom.{lowerCaseType}_read_own":"Allows to read only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read_own`."}}}}},"parameters":{"trait_validateReferences_bulk":{"name":"validateReferences","in":"query","required":false,"schema":{"type":"boolean","default":false},"description":"When set to true, references are validated if the provided resources exist. If set to false, validation is skipped.\n"}},"schemas":{"CustomInstanceUpdate":{"type":"object","properties":{"name":{"type":"object","description":"Localized custom type name in a form of a map of translations."},"mixins":{"type":"string","description":"A key-value map of additional attributes."},"metadata":{"type":"object","properties":{"version":{"type":"integer","description":"Version of the custom instance.  If provided, it will be validated against the current entity version."},"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema."}}}}},"BulkResponse":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer","description":"Index of the processed item, matching the item position in request body."},"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status description"},"message":{"type":"string","description":"Error message."},"details":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string","description":"Error details."}}}}}}},"ErrorResponse":{"required":["code","message","status"],"type":"object","properties":{"id":{"type":"string","nullable":true},"code":{"type":"integer","format":"int32"},"status":{"type":"string"},"message":{"type":"string"},"errorCode":{"type":"string","nullable":true},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}},"responses":{"Unauthorized_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired. It usually means that the tenant from the token does not match tenant from path.","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Forbidden_403":{"description":"Permission denied due to insufficient rights. This may happen when the request does not contain sufficient scopes for the given query values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/schema/{tenant}/custom-entities/{type}/instances/bulk":{"put":{"summary":"Upserting custom instances in bulk","description":"Upserts multiple custom instances. The maximum batch size is 200.","tags":["Custom Instance"],"parameters":[{"$ref":"#/components/parameters/trait_validateReferences_bulk"}],"requestBody":{"content":{"application/json":{"schema":{"type":"array","items":{"allOf":[{"type":"object","properties":{"id":{"type":"string","description":"Custom instance id"}},"required":["id"]},{"$ref":"#/components/schemas/CustomInstanceUpdate"}]}}}}},"responses":{"207":{"description":"Bulk operation was successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized_401"},"403":{"$ref":"#/components/responses/Forbidden_403"}},"operationId":"PUT-schema-create-custom-instances-bulk"}}}}
```

## Deleting custom instances in bulk

> Removes multiple custom instances.\
> \
> \*\*Note\*\*:\
> The IDs of items should be defined in the request body as an array of strings.\
> \
> \*\*Example\*\*: \`\["firstId", "secondId", "thirdId"]\`

```json
{"openapi":"3.0.1","info":{"title":"Schema Service","version":"0.0.1"},"tags":[{"name":"Custom Instance"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["schema.custominstance_manage","custom.{lowerCaseType}_manage","custom.{lowerCaseType}_manage_own"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"schema.schema_manage":"Required for managing schemas.","schema.schema_read":"Required for reading schemas.","schema.custominstance_read":"Read custom instances of any custom schema type.","schema.custominstance_manage":"Manage custom instances of any custom schema type.","custom.{lowerCaseType}_manage":"Manage custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage`.","custom.{lowerCaseType}_manage_own":"Allows to manage only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_manage_own`.","custom.{lowerCaseType}_read":"Read custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read`.","custom.{lowerCaseType}_read_own":"Allows to read only your own custom instances of a given type. For example, for type `DOCUMENT` → `custom.document_read_own`."}}}}},"schemas":{"BulkResponse":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer","description":"Index of the processed item, matching the item position in request body."},"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status description"},"message":{"type":"string","description":"Error message."},"details":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string","description":"Error details."}}}}}}},"ErrorResponse":{"required":["code","message","status"],"type":"object","properties":{"id":{"type":"string","nullable":true},"code":{"type":"integer","format":"int32"},"status":{"type":"string"},"message":{"type":"string"},"errorCode":{"type":"string","nullable":true},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}},"responses":{"Unauthorized_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired. It usually means that the tenant from the token does not match tenant from path.","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Forbidden_403":{"description":"Permission denied due to insufficient rights. This may happen when the request does not contain sufficient scopes for the given query values.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/schema/{tenant}/custom-entities/{type}/instances/bulk":{"delete":{"summary":"Deleting custom instances in bulk","description":"Removes multiple custom instances.\n\n**Note**:\nThe IDs of items should be defined in the request body as an array of strings.\n\n**Example**: `[\"firstId\", \"secondId\", \"thirdId\"]`","tags":["Custom Instance"],"responses":{"207":{"description":"Bulk operation was successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized_401"},"403":{"$ref":"#/components/responses/Forbidden_403"}},"operationId":"DELETE-schema-create-custom-instances-bulk"}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.emporix.io/api-references/api-guides/utilities/schema/api-reference/custom-instance.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
