This article will guide you on how to create a  time code through BioStar 2 TA API.


 * A new API for Time Attendance has been added with BioStar v2.8.13. *

 

For a more general introduction to TA API (including how to access the TA Swagger), please refer to the link below:

 [BioStar 2 TA API] Introduction BioStar 2 TA API 

For other articled related to BioStar 2 TA Time Codes:

[BioStar 2 TA API] Search Time Codes

[BioStar 2 TA API] Modify Time Codes

[BioStar 2 TA API] Delete Time Codes

 

 

One of the most basic parts of BioStar 2 TA is the Time Code. 

As you can see in the below screenshot, you can create a time code through the BioStar 2 Web UI.

This article will show you how to do the same action through API. 

 

텍스트이(가) 표시된 사진

자동 생성된 설명

 

Part 1. API Parameters

 

[POST]: /tna/pay_codes

This API creates a new time code. 

[Body Parameters] 

ParametersTypeRequiredDescription
accumulate_toward_overtimeBoolean
YTrue for overtime management
colorStringYColor of time code
count_as_attendance
BooleanYTrue for attendance management
descriptionStringNDescription
nameStringYName of time code
time_rateDoubleY0-10 rate
track_on_leave_managementBooleanYTrue for leave management
typeStringY["WORKED" , "NOT_WORKED"]



Part 2. Request Body & Response Model


[Example Value/Parameters Model]

{

     "accumulate_toward_overtime": false,

     "color": "#00ff00",

     "count_as_attendance": true,

     "description": "Made by API",

     "name": "Time Code Made by API",

     "time_rate": 1,

     "track_on_leave_management": false,

     "type": "WORKED"

}

 

[Response: successful]

{

    "id": 5,

    "message": "Created successfully",

       "message_key": "CREATED",

    "language": "en",

       "status_code": "CREATED"

}


[Response: Fail: missing required input]

{

    "message": "type is required.",

    "message_key": "REQUIRED_FIELD",

    "language": "en",

    "status_code": "REQUIRED_FIELD"

}

 


Part 3. POST /tna/pay_codes via Postman

 

[Request Example: Headers] 

*You must log-in to T&A to use [POST] /tna/pay_codes

*Unlike be-session-id for AC New Local API, bs-ta-session-id is sent in the Cookie automatically once you log-in via TA log-in API. So there's no need for you to save and update it separately. 

 

[Request Example] 

 

 

[Response Example: body] 

 

 After calling the API, as you can see in the BioStar web UI, there is a new time code added with the name "TESTING".