Examples and Testing
Our sandbox environment can help you understand how our endpoints behave and the possible outcomes considering error scenarios.
We've included a table for every endpoint showing all possible scenarios. Consider each scenario to ensure a smooth integration with Wellhub.
Create Many
Status Code | Scenario |
---|---|
201 Created | Successful Request |
422 Unprocessable Entity | Error: Identifier key with wrong format, duplicated or missing |
Sample 1. Successful request1curl --location --request POST '{{environment-url}}/eligibility/v1/employees/bulk-create' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}' \4--data-raw '[5 {6 "full_name": "John Doe",7 "email": "john.doe@acme.com",8 "national_id": "null",9 "employee_id": "null"10 },11 {12 "full_name": "Mary Doe",13 "email": "mary.doe@acme.com",14 "national_id": "null",15 "employee_id": "null"16 }17]'18# Expected response:19[20 {21 "email": "john.doe@acme.com"22 },23 {24 "email": "mary.doe@acme.com"25 }26]
HTTP status code: 201 Created
Sample 2. Error: duplicated email1curl --location --request POST '{{environment-url}}/eligibility/v1/employees/bulk-create' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}' \4--data-raw '[5 {6 "full_name": "Peter Doe",7 "email": "new@acme.com",8 "national_id": "null",9 "employee_id": "null"10 },11 {12 "full_name": "Mary Doe",13 "email": "another_new@acme.com",14 "national_id": "null",15 "employee_id": "null"16 },17 {18 "full_name": "John Doe",19 "email": "duplicated@acme.com",20 "national_id": "null",21 "employee_id": "null"22 }23]'24# Expected response:25{26 "errors": [27 {28 "index": 2,29 "errors": [30 "field": "EMAIL",31 "category": "conflict",32 "description": "Email is already in use",33 "value": "duplicated@acme.com"34 ]35 },36 ]37}
HTTP status code: 422 Unprocessable Entity
Sample 3. Error: email with wrong format1curl --location --request POST '{{environment-url}}/eligibility/v1/employees/bulk-create' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}' \4--data-raw '[5 {6 "full_name": "John Doe",7 "email": "invalid-email@@acme",8 "national_id": "null",9 "employee_id": "null"10 },11 {12 "full_name": "Vera Doe",13 "email": "new@acme",14 "national_id": "null",15 "employee_id": "null"16 }17]'18# Expected response:19{20 "errors": [21 {22 "index": 0,23 "errors": [24 "field": "EMAIL",25 "category": "format",26 "description": "Email invalid format",27 "value": "invalid-email@@acme"28 ]29 },30 ]31}
HTTP status code: 422 Unprocessable Entity
Sample 4. Error: national id with wrong format1curl --location --request POST '{{environment-url}}/eligibility/v1/employees/bulk-create' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}' \4--data-raw '[5 {6 "full_name": "Malcom Doe",7 "email": "new@email.com",8 "national_id": "123",9 "employee_id": "null"10 },11 {12 "full_name": "John Doe",13 "email": "null",14 "national_id": "123",15 "employee_id": "null"16 }17]'18# Expected response:19{20 "errors": [21 {22 "index": 1,23 "errors": [24 "field": "NATIONAL_ID",25 "category": "format",26 "description": "National id invalid format",27 "value": "invalid-email@@acme"28 ]29 },30 ]31}
HTTP status code: 422 Unprocessable Entity
Update Many
Status Code | Scenario |
---|---|
204 No Content | Successful Request |
422 Unprocessable Entity | Error: Identifier key with wrong format, duplicated or missing |
Sample 5. Success request1curl --location --request POST '2{{environment-url}}/eligibility/v1/employees/bulk-update' \3--header 'Content-Type: application/json' \4--header 'Authorization: Bearer {{Wellhub API Key}}' \5--data-raw '[6 {7 "full_name": "John Doe",8 "email": "john.doe@acme.com",9 "national_id": "null",10 "employee_id": "null"11 }12]'13#Expected response:
HTTP status code: 204 No Content
Sample 6. Error: email with wrong format1curl --location --request POST '{{environment-url}}/eligibility/v1/employees/bulk-update' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}' \4--data-raw '[5 {6 "full_name": "John Doe",7 "email": "john.doe@@acme.com",8 "national_id": "null",9 "employee_id": "null"10 },11 {12 "full_name": "Tonya Doe",13 "email": "to_update@acme",14 "national_id": "null",15 "employee_id": "null"16 }17]'18# Expected response:19{20 "employee_errors": [21 {22 "index": 0,23 "employee_id": null,24 "errors": [25 "field": "EMAIL",26 "category": "format",27 "description": "Email invalid format",28 "value": "john.doe@@acme.com"29 ]30 }31 ]32}
HTTP status code: 422 Unprocessable Entity
Sample 7. Error: no employee for ID (when it is the identifier key)1curl --location --request POST '{{environment-url}}/eligibility/v1/employees/bulk-update' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}' \4--data-raw '[5 {6 "full_name": "Chris Doe",7 "email": "to_update_chris@acme",8 "national_id": "null",9 "employee_id": "abc123"10 },11 {12 "full_name": "John Doe",13 "email": "john.doe@@acme.com",14 "national_id": "null",15 "employee_id": "null"16 },17 {18 "full_name": "Drew Doe",19 "email": "to_update_drew@acme",20 "national_id": "null",21 "employee_id": "abc124"22 }23]'24# Expected response:25{26 "employee_errors": [27 {28 "index": 1,29 "employee_id": null,30 "errors": [31 "field": "EMPLOYEE_ID",32 "category": "format",33 "description": "Employee ID is null or empty",34 "value": "null"35 ]36 }37 ]38}
HTTP status code: 422 Unprocessable Entity
Sample 8. Error: duplicated email (when other employee has the email we're attempting)1curl --location --request POST '{{environment-url}}/eligibility/v1/employees/bulk-update' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}' \4--data-raw '[5 {6 "full_name": "John Doe",7 "email": "doe.email@acme.com",8 "national_id": "null",9 "employee_id": "null"10 },11 {12 "full_name": "Mary Doe",13 "email": "doe.email@acme.com",14 "national_id": "null",15 "employee_id": "null"16 }17]'18# Expected response:19{20 "employee_errors": [21 {22 "index": 0,23 "employee_id": null,24 "errors": [25 "field": "EMAIL",26 "category": "duplicate",27 "description": "Email is duplicated",28 "value": "doe.email@acme.com"29 ]30 },31 {32 "index": 1,33 "employee_id": null,34 "errors": [35 "field": "EMAIL",36 "category": "duplicate",37 "description": "Email is duplicated",38 "value": "doe.email@acme.com"39 ]40 }41 ]42}
HTTP status code: 422 Unprocessable Entity
Delete Many
Status Code | Scenario |
---|---|
204 No Content | Successful Request |
422 Unprocessable Entity | Error: Identifier key with wrong format, duplicated or missing |
Sample 9. Success request1curl --location --request POST \ '{{environment-url}}/eligibility/v1/employees/bulk-update' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}' \4--data-raw '[5 {6 "email": "doe.email@acme.com"7 }8]'9#Expected response:
HTTP status code: 204 No Content
Sample 10. Error: email with wrong format1curl --location --request POST \ '{{environment-url}}/eligibility/v1/employees/bulk-update' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}' \4--data-raw '[5 {6 "email": "doe.email@@acme.com"7 },8 {9 "email": "doe.email_correct@acme.com"10 },11 {12 "email": "doe.email_correct_too@acme.com"13 }14]'1516# Expected response:17{18 "employee_errors": [19 {20 "index": 0,21 "employee_id": null,22 "errors": [23 "field": "EMAIL",24 "category": "format",25 "description": "Email has invalid format",26 "value": "doe.email@@acme.com"27 ]28 }29 ]30}
HTTP status code: 422 Unprocessable Entity
Sample 11. Error: no employee for ID1curl --location --request POST \ '{{environment-url}}/eligibility/v1/employees/bulk-update' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}' \4--data-raw '[5 {6 "email": "email@email.com"7 },8 {9 "email": ""10 }11]'1213# Expected response:14{15 "employee_errors": [16 {17 "index": 1,18 "employee_id": null,19 "errors": [20 "field": "EMAIL",21 "category": "NullOrEmpty",22 "description": "Email is empty",23 "value": ""24 ]25 }26 ]27}
HTTP status code: 422 Unprocessable Entity
Get One
Status Code | Scenario |
---|---|
200 OK | Successful Request |
400 Bad Request | Error: invalid main eligibility identifier (e.g. expected email, sent national ID) |
404 Not Found | Error: no employee for given identifier |
Sample 12. Success request1curl --location --request GET \ '{{environment-url}}/eligibility/v2/employees/carol.fisher@acme.com' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}'4# Expected response:5{6 "full_name": "Carol Fisher",7 "email": "carol.fisher@acme.com",8 "national_id": "03963105089",9 "employee_id": "abc123",10 "updated_at": "2023-06-15T10:03:18.427465-03:00",11 "deleted_at": null12}
HTTP status code: 200 OK
Sample 13. Error: invalid main eligibility identifier (e.g. expected email, sent national ID)1curl --location --request PUT '{{environment-url}}/eligibility/v2/employees/03963105089' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}'4# Expected response:5{6 "timestamp": "2023-06-27T15:35:52.080825+01:00",7 "type": "validation error",8 "message": "eligible employee identifier validation(s) has failed",9 "errors": [10 "field": "EMAIL",11 "category": "Format",12 "description": "Email has invalid format",13 "value": "03963105089"14 ]15}
HTTP status code: 400 Bad Request
Sample 14. Error: no employee for given identifier1curl --location --request GET \ '{{environment-url}}/eligibility/v2/employees/idont@exist.com' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}'4# Expected response:5{6 "timestamp": "2023-06-27T15:35:16.798611+01:00",7 "type": "not found",8 "message": "employee does not exist",9 "errors": null10}
HTTP status code: 404 Not Found
Get Many
Status Code | Scenario |
---|---|
200 OK | Successful Request |
200 OK | Success request, page contains no data (e.g. requests page 10, but we only have 2) |
Sample 15. Success request1curl --location --request GET '{{environment-url}}/eligibility/v1/employees' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}'4# Expected response:5{6 "page_info": {7 "current_page": 2,8 "total_pages": 2,9 "total_elements": 52,10 "offset_start": 51,11 "offset_end": 52,12 "page_size": 5013 },14 "items": [15 {16 "full_name": "Carol Fisher",17 "email": "carol.fisher@acme.com",18 "national_id": "03963105089",19 "employee_id": "abc123",20 "updated_at": "2023-06-15T10:03:18.427465-03:00",21 "deleted_at": null22 },23 {24 "full_name": "John Doe",25 "email": "john.doe@acme.com",26 "national_id": "20366667017",27 "employee_id": "abc321",28 "updated_at": "2023-06-15T10:03:18.427465-03:00",29 "deleted_at": null30 }31 ]32}
HTTP status code: 200 OK
Sample 14. Success request, the page contains no data (requests page 10, but we only have 2)1curl --location --request GET '{{environment-url}}/eligibility/v1/employees?page=10' \2--header 'Content-Type: application/json' \3--header 'Authorization: Bearer {{Wellhub API Key}}'4# Expected response:5{6 "page_info": {7 "current_page": 10,8 "total_pages": 2,9 "total_elements": 52,10 "offset_start": 0,11 "offset_end": 0,12 "page_size": 5013 },14 "items": []15}
HTTP status code: 200 OK