POST
/
stores
/
store-employees
/
Link Store to Employee
curl --request POST \
  --url https://api-staging.luladelivery.store/stores/store-employees/ \
  --header 'Content-Type: application/json' \
  --data '{
  "store_ids": [
    {}
  ],
  "employee_id": "<string>",
  "company_id": 123,
  "user_id": 123
}'
{
  "count": 123,
  "successful_links": [
    {
      "store_id": "<string>",
      "employee_id": "<string>",
      "access_level": "<string>",
      "linked_at": "<string>"
    }
  ],
  "failed_links": [
    {
      "store_id": "<string>",
      "error": "<string>",
      "error_code": "<string>"
    }
  ]
}
This endpoint creates employee relationships between a new employee and multiple stores in a single operation. It’s particularly useful for multi-store employees, area managers, or support staff who need access to multiple store locations.

Request Body

store_ids
array
required
Array of store IDs to link the employee toExample: [“b2b56ffb-e198-49f3-a1bc-f36ac70f9501”, “d7c17a59-01e1-48f2-a326-2bbd3c888205”]
employee_id
string
required
The unique employee identifier (UUID format) for this employeeExample: “30523fd1-e108-41d0-a02d-f5907336f2e4”
company_id
number
required
The company ID that owns the stores being linkedExample: 1000022
user_id
number
required
The user ID of the employee being linked to storesExample: 1000305

Request Example

{
    "store_ids": [
        "b2b56ffb-e198-49f3-a1bc-f36ac70f9501",
        "d7c17a59-01e1-48f2-a326-2bbd3c888205",
        "449235c1-3d04-4519-998b-40d2a621e5e0"
    ],
    "employee_id": "30523fd1-e108-41d0-a02d-f5907336f2e4",
    "company_id": 1000022,
    "user_id": 1000305
}

Response

count
number
Number of stores successfully linked to the employee
Array of successfully created store-employee relationships
Array of stores that failed to link with error details

Response Example

{
    "count": 2,
    "successful_links": [
        {
            "store_id": "b2b56ffb-e198-49f3-a1bc-f36ac70f9501",
            "employee_id": "30523fd1-e108-41d0-a02d-f5907336f2e4",
            "access_level": "store_employee",
            "linked_at": "2024-11-15T10:30:00.000Z"
        },
        {
            "store_id": "d7c17a59-01e1-48f2-a326-2bbd3c888205",
            "employee_id": "30523fd1-e108-41d0-a02d-f5907336f2e4",
            "access_level": "store_employee",
            "linked_at": "2024-11-15T10:30:01.000Z"
        }
    ],
    "failed_links": [
        {
            "store_id": "449235c1-3d04-4519-998b-40d2a621e5e0",
            "error": "Store not found or not accessible",
            "error_code": "STORE_NOT_FOUND"
        }
    ]
}

Multi-Store Employee Types

Batch Operation Benefits

Validation and Error Handling

Use Cases

Error Recovery

Partial Success Handling: This endpoint can succeed partially - some stores may link successfully while others fail. Always check both the count and failed_links array.
Company Security: All stores must belong to the same company for security reasons. Cross-company employee access requires separate authorization processes.
Performance Consideration: While efficient for multiple stores, very large store lists may take longer to process. Consider batching for extremely large operations.