# Customers Assignments

Manage customer assignments to segments

## Retrieving all customer assignments for a customer segment

> \
> Retrieves all customer assignments for a given customer segment.<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"CustomerAccessToken":["customersegment.segment_read","customersegment.segment_read_own"]}],"components":{"securitySchemes":{},"schemas":{"CustomerAssignmentResponse":{"allOf":[{"type":"object","properties":{"legalEntity":{"$ref":"#/components/schemas/LegalEntity"}}},{"$ref":"#/components/schemas/CustomerAssignmentB2CResponse"}]},"LegalEntity":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing legal entity."},"name":{"type":"string","description":"Name of a legal entity."}}},"CustomerAssignmentB2CResponse":{"allOf":[{"type":"object","properties":{"customer":{"$ref":"#/components/schemas/Customer"}}},{"type":"object","properties":{"assignmentType":{"type":"string","enum":["MANUAL","AUTOMATIC"]}}},{"$ref":"#/components/schemas/CustomerAssignmentUpsert"},{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/MetadataResponse"}}}]},"Customer":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing customer."},"firstName":{"type":"string","description":"Customer's first name."},"lastName":{"type":"string","description":"Customer's last name."},"email":{"type":"string","description":"Customer's e-mail address."}}},"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"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.","additionalProperties":true}}},"MetadataResponse":{"allOf":[{"type":"object","properties":{"createdAt":{"description":"The creation date.","type":"string","format":"date-time"},"modifiedAt":{"description":"The modification date.","type":"string","format":"date-time"}}},{"$ref":"#/components/schemas/MetadataUpdate"}]},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"parameters":{"qParam":{"in":"query","name":"q","description":"A standard query parameter is used to search for specific values. \n\nSee: [Standard practises - Query parameter](https://developer.emporix.io/api-references/standard-practices/q-param)\n","schema":{"type":"string"}},"pageSize":{"schema":{"type":"string"},"in":"query","name":"pageSize","description":"The number of documents to be retrieved per page."},"pageNumber":{"schema":{"type":"string"},"in":"query","name":"pageNumber","description":"The page number to be retrieved. The size of the pages should be specified by the pageSize parameter."},"sort":{"schema":{"type":"string"},"in":"query","name":"sort","description":"List of properties used to sort the results, separated by colons."},"fields":{"schema":{"type":"string"},"in":"query","name":"fields","description":"Fields to be returned in the response."},"xTotalCount":{"schema":{"type":"boolean"},"in":"header","name":"X-Total-Count","description":"Flag indicating whether the total number of retrieved results should be returned."}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers":{"get":{"summary":"Retrieving all customer assignments for a customer segment","tags":["Customers Assignments"],"description":"\nRetrieves all customer assignments for a given customer segment.\n","responses":{"200":{"description":"Customer assignments for a customer segment were successfully retrieved.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CustomerAssignmentResponse"}}}}},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"}},"operationId":"GET-customer-segment-retrieve-customers","parameters":[{"$ref":"#/components/parameters/qParam"},{"$ref":"#/components/parameters/pageSize"},{"$ref":"#/components/parameters/pageNumber"},{"$ref":"#/components/parameters/sort"},{"$ref":"#/components/parameters/fields"},{"$ref":"#/components/parameters/xTotalCount"}]}}}}
```

## Searching with parameters for customer assignments

> \
> Returns all customer assignments that match provided criteria.<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"CustomerAccessToken":["customersegment.segment_read"]}],"components":{"securitySchemes":{},"schemas":{"SegmentsSearch":{"type":"object","properties":{"q":{"type":"string","description":"A standard query parameter is used to search for specific values. \n\nSee: [Standard practises - Query parameter](https://developer.emporix.io/api-references/standard-practices/q-param/)\n"}}},"CustomerAssignmentResponse":{"allOf":[{"type":"object","properties":{"legalEntity":{"$ref":"#/components/schemas/LegalEntity"}}},{"$ref":"#/components/schemas/CustomerAssignmentB2CResponse"}]},"LegalEntity":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing legal entity."},"name":{"type":"string","description":"Name of a legal entity."}}},"CustomerAssignmentB2CResponse":{"allOf":[{"type":"object","properties":{"customer":{"$ref":"#/components/schemas/Customer"}}},{"type":"object","properties":{"assignmentType":{"type":"string","enum":["MANUAL","AUTOMATIC"]}}},{"$ref":"#/components/schemas/CustomerAssignmentUpsert"},{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/MetadataResponse"}}}]},"Customer":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing customer."},"firstName":{"type":"string","description":"Customer's first name."},"lastName":{"type":"string","description":"Customer's last name."},"email":{"type":"string","description":"Customer's e-mail address."}}},"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"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.","additionalProperties":true}}},"MetadataResponse":{"allOf":[{"type":"object","properties":{"createdAt":{"description":"The creation date.","type":"string","format":"date-time"},"modifiedAt":{"description":"The modification date.","type":"string","format":"date-time"}}},{"$ref":"#/components/schemas/MetadataUpdate"}]},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_BadRequest_400":{"description":"Bad request due to validation, incorrect parameters, etc.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"parameters":{"pageSize":{"schema":{"type":"string"},"in":"query","name":"pageSize","description":"The number of documents to be retrieved per page."},"pageNumber":{"schema":{"type":"string"},"in":"query","name":"pageNumber","description":"The page number to be retrieved. The size of the pages should be specified by the pageSize parameter."},"sort":{"schema":{"type":"string"},"in":"query","name":"sort","description":"List of properties used to sort the results, separated by colons."},"fields":{"schema":{"type":"string"},"in":"query","name":"fields","description":"Fields to be returned in the response."},"xTotalCount":{"schema":{"type":"boolean"},"in":"header","name":"X-Total-Count","description":"Flag indicating whether the total number of retrieved results should be returned."}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/search":{"post":{"summary":"Searching with parameters for customer assignments","tags":["Customers Assignments"],"description":"\nReturns all customer assignments that match provided criteria.\n","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentsSearch"}}}},"responses":{"200":{"description":"Customer assignments for a customer segment were successfully retrieved.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CustomerAssignmentResponse"}}}}},"400":{"$ref":"#/components/responses/Common_response_BadRequest_400"},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"}},"operationId":"POST-customer-segment-search-customers","parameters":[{"$ref":"#/components/parameters/pageSize"},{"$ref":"#/components/parameters/pageNumber"},{"$ref":"#/components/parameters/sort"},{"$ref":"#/components/parameters/fields"},{"$ref":"#/components/parameters/xTotalCount"}]}}}}
```

## \[B2C] Retrieving a customer assignment for a customer segment

> \
> Retrieves a customer with specified customerId assigned to a customer segment.<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"CustomerAccessToken":["customersegment.segment_read"]}],"components":{"securitySchemes":{},"schemas":{"CustomerAssignmentB2CResponse":{"allOf":[{"type":"object","properties":{"customer":{"$ref":"#/components/schemas/Customer"}}},{"type":"object","properties":{"assignmentType":{"type":"string","enum":["MANUAL","AUTOMATIC"]}}},{"$ref":"#/components/schemas/CustomerAssignmentUpsert"},{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/MetadataResponse"}}}]},"Customer":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing customer."},"firstName":{"type":"string","description":"Customer's first name."},"lastName":{"type":"string","description":"Customer's last name."},"email":{"type":"string","description":"Customer's e-mail address."}}},"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"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.","additionalProperties":true}}},"MetadataResponse":{"allOf":[{"type":"object","properties":{"createdAt":{"description":"The creation date.","type":"string","format":"date-time"},"modifiedAt":{"description":"The modification date.","type":"string","format":"date-time"}}},{"$ref":"#/components/schemas/MetadataUpdate"}]},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_NotFound_404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"parameters":{"fields":{"schema":{"type":"string"},"in":"query","name":"fields","description":"Fields to be returned in the response."}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/{customerId}":{"get":{"summary":"[B2C] Retrieving a customer assignment for a customer segment","tags":["Customers Assignments"],"description":"\nRetrieves a customer with specified customerId assigned to a customer segment.\n","responses":{"200":{"description":"Customer assignment for a customer segment was successfully retrieved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerAssignmentB2CResponse"}}}},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"},"404":{"$ref":"#/components/responses/Common_response_NotFound_404"}},"operationId":"GET-customer-segment-retrieve-customer-by-customerId","parameters":[{"$ref":"#/components/parameters/fields"}]}}}}
```

## \[B2C] Updating a customer assignment for a customer segment

> \
> Performs \`UPSERT\` operation. Updates a customer assigned to a customer segment. A new customer assignment is created if it's not present in the system.<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"CustomerAccessToken":["customersegment.segment_manage"]}],"components":{"securitySchemes":{},"schemas":{"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"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.","additionalProperties":true}}},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_BadRequest_400":{"description":"Bad request due to validation, incorrect parameters, etc.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Conflict_409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/{customerId}":{"put":{"summary":"[B2C] Updating a customer assignment for a customer segment","tags":["Customers Assignments"],"operationId":"PUT-customer-segment-update-customer-by-customerId","description":"\nPerforms `UPSERT` operation. Updates a customer assigned to a customer segment. A new customer assignment is created if it's not present in the system.\n","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerAssignmentUpsert"}}}},"responses":{"201":{"description":"A new customer assignment was successfully created."},"204":{"description":"Customer assignment was successfully updated."},"400":{"$ref":"#/components/responses/Common_response_BadRequest_400"},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"},"409":{"$ref":"#/components/responses/Common_response_Conflict_409"}}}}}}
```

## \[B2C] Removing a customer from customer segment

> \
> Removes customer assignment.<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"CustomerAccessToken":["customersegment.segment_manage"]}],"components":{"securitySchemes":{},"responses":{"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/{customerId}":{"delete":{"summary":"[B2C] Removing a customer from customer segment","tags":["Customers Assignments"],"operationId":"DELETE-customer-segment-remove-customer-by-customerId","description":"\nRemoves customer assignment.\n","responses":{"204":{"description":"Customer assignment was successfully removed."},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"}}}}}}
```

## \[B2B] Retrieving a customer assignment for a customer segment

> \
> Retrieves a customer with specified customerId and companyId assigned to a customer segment.<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"CustomerAccessToken":["customersegment.segment_read"]}],"components":{"securitySchemes":{},"schemas":{"CustomerAssignmentResponse":{"allOf":[{"type":"object","properties":{"legalEntity":{"$ref":"#/components/schemas/LegalEntity"}}},{"$ref":"#/components/schemas/CustomerAssignmentB2CResponse"}]},"LegalEntity":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing legal entity."},"name":{"type":"string","description":"Name of a legal entity."}}},"CustomerAssignmentB2CResponse":{"allOf":[{"type":"object","properties":{"customer":{"$ref":"#/components/schemas/Customer"}}},{"type":"object","properties":{"assignmentType":{"type":"string","enum":["MANUAL","AUTOMATIC"]}}},{"$ref":"#/components/schemas/CustomerAssignmentUpsert"},{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/MetadataResponse"}}}]},"Customer":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing customer."},"firstName":{"type":"string","description":"Customer's first name."},"lastName":{"type":"string","description":"Customer's last name."},"email":{"type":"string","description":"Customer's e-mail address."}}},"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"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.","additionalProperties":true}}},"MetadataResponse":{"allOf":[{"type":"object","properties":{"createdAt":{"description":"The creation date.","type":"string","format":"date-time"},"modifiedAt":{"description":"The modification date.","type":"string","format":"date-time"}}},{"$ref":"#/components/schemas/MetadataUpdate"}]},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_NotFound_404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"parameters":{"fields":{"schema":{"type":"string"},"in":"query","name":"fields","description":"Fields to be returned in the response."}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/{customerId}/{legalEntityId}":{"get":{"summary":"[B2B] Retrieving a customer assignment for a customer segment","tags":["Customers Assignments"],"description":"\nRetrieves a customer with specified customerId and companyId assigned to a customer segment.\n","responses":{"200":{"description":"Customer assignment for a customer segment was successfully retrieved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerAssignmentResponse"}}}},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"},"404":{"$ref":"#/components/responses/Common_response_NotFound_404"}},"operationId":"GET-customer-segment-retrieve-customer","parameters":[{"$ref":"#/components/parameters/fields"}]}}}}
```

## \[B2B] Updating a customer assignment for a customer segment

> \
> Performs \`UPSERT\` operation. Updates a customer assigned to a customer segment. A new customer assignment is created if it's not present in the system.<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"CustomerAccessToken":["customersegment.segment_manage"]}],"components":{"securitySchemes":{},"schemas":{"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"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.","additionalProperties":true}}},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_BadRequest_400":{"description":"Bad request due to validation, incorrect parameters, etc.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Conflict_409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/{customerId}/{legalEntityId}":{"put":{"summary":"[B2B] Updating a customer assignment for a customer segment","tags":["Customers Assignments"],"operationId":"PUT-customer-segment-update-customer","description":"\nPerforms `UPSERT` operation. Updates a customer assigned to a customer segment. A new customer assignment is created if it's not present in the system.\n","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerAssignmentUpsert"}}}},"responses":{"201":{"description":"A new customer assignment was successfully created."},"204":{"description":"Customer assignment was successfully updated."},"400":{"$ref":"#/components/responses/Common_response_BadRequest_400"},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"},"409":{"$ref":"#/components/responses/Common_response_Conflict_409"}}}}}}
```

## \[B2B] Removing a customer from customer segment

> \
> Removes customer assignment.<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"CustomerAccessToken":["customersegment.segment_manage"]}],"components":{"securitySchemes":{},"responses":{"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/{customerId}/{legalEntityId}":{"delete":{"summary":"[B2B] Removing a customer from customer segment","tags":["Customers Assignments"],"operationId":"DELETE-customer-segment-remove-customer","description":"\nRemoves customer assignment.\n","responses":{"204":{"description":"Customer assignment was successfully removed."},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"}}}}}}
```

## Updating customer assignments for a customer segment in bulk

> \
> Performs \`UPSERT\` operation. Updates multiple customer assignments to a customer segment. The maximum batch size is 200.<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"CustomerAccessToken":["customersegment.segment_manage"]}],"components":{"securitySchemes":{},"schemas":{"CustomerAssignmentUpsertBulk":{"allOf":[{"$ref":"#/components/schemas/CustomerAssignmentUpsert"},{"type":"object","properties":{"customerId":{"type":"string","description":"Unique identifier of an existing customer."},"legalEntityId":{"type":"string","description":"Unique identifier of an existing legal entity. It should be omitted for B2C."}}}]},"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"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.","additionalProperties":true}}},"BulkAssignmentResponse":{"type":"object","properties":{"index":{"type":"integer","description":"Index of the processed item, matching the item position in request body.\n"},"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status description."},"message":{"type":"string","description":"Error message."}}},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_BadRequest_400":{"description":"Bad request due to validation, incorrect parameters, etc.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/bulk":{"put":{"summary":"Updating customer assignments for a customer segment in bulk","tags":["Customers Assignments"],"operationId":"PUT-customer-segment-update-customers-bulk","description":"\nPerforms `UPSERT` operation. Updates multiple customer assignments to a customer segment. The maximum batch size is 200.\n","requestBody":{"content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CustomerAssignmentUpsertBulk"}}}}},"responses":{"207":{"description":"Multi-status response.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/BulkAssignmentResponse"}}}}},"400":{"$ref":"#/components/responses/Common_response_BadRequest_400"},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"}}}}}}
```

## Removing customers from customer segment in bulk

> \
> Removes multiple customer assignments to a customer segment. The maximum batch size is 200.\
> \
> \### The request body for this endpoint is array of objects with \`customerId\` and \`legalEntityId\` fields.\
> \#### Example: \`\[{"customerId": "firstCustomerId", "legalEntityId": "firstLegalEntityId"}, {"customerId": "secondCustomerId", "legalEntityId": "secondLegalEntityId"}, {"customerId": "thirdCustomerId", "legalEntityId": "thirdLegalEntityId"}]\`<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"CustomerAccessToken":["customersegment.segment_manage"]}],"components":{"securitySchemes":{},"schemas":{"BulkAssignmentResponse":{"type":"object","properties":{"index":{"type":"integer","description":"Index of the processed item, matching the item position in request body.\n"},"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status description."},"message":{"type":"string","description":"Error message."}}},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_BadRequest_400":{"description":"Bad request due to validation, incorrect parameters, etc.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/bulk":{"delete":{"summary":"Removing customers from customer segment in bulk","tags":["Customers Assignments"],"operationId":"DELETE-customer-segment-remove-customers-bulk","description":"\nRemoves multiple customer assignments to a customer segment. The maximum batch size is 200.\n\n### The request body for this endpoint is array of objects with `customerId` and `legalEntityId` fields.\n#### Example: `[{\"customerId\": \"firstCustomerId\", \"legalEntityId\": \"firstLegalEntityId\"}, {\"customerId\": \"secondCustomerId\", \"legalEntityId\": \"secondLegalEntityId\"}, {\"customerId\": \"thirdCustomerId\", \"legalEntityId\": \"thirdLegalEntityId\"}]`\n","responses":{"207":{"description":"Multi-status response.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/BulkAssignmentResponse"}}}}},"400":{"$ref":"#/components/responses/Common_response_BadRequest_400"},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"}}}}}}
```


---

# 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/companies-and-customers/customer-segments/api-reference/customers-assignments.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.
