Fit2Trade API documentation.
Reference documentation for integrating with Fit2Trade user data, roles, course completions and authenticated user access.
API access must be enabled for the client account by Fit2Trade. Once enabled, an access token and refresh token are generated and supplied for API access.
Overview
Use the Fit2Trade API to access or modify data for an enabled client account. Each request requires the API v2 accept header and bearer-token authorisation.
Base URLs
https://fit2trade.apphttps://f2tlab.comRequired request headers
| Header | Value |
|---|---|
| Accept | application/app.fit2trade.v2 Required · fixed value |
| Authorization | Bearer [Access Token] Required |
| Content-Type | application/json Used by JSON request endpoints |
Responses and errors
Regardless of the HTTP return code, the response body uses a consistent Status, Error and Data structure. Check Status first to determine whether a request was processed successfully. On success, ErrorCode is 0 and Message is blank.
{
"Status": "OK/ERROR",
"Error": {
"ErrorCode": 123,
"Message": "error details"
},
"Data": {}
}
The server returns HTTP status 200 unless one of the following conditions occurs.
HTTP status codes
| Status | Description |
|---|---|
403 | Token expired, token invalid, or required headers are missing. |
400 | Wrong data format or too many rows. |
500 | Unexpected error. |
Error codes
| ErrorCode | Description |
|---|---|
0 | No error |
2000 | System error |
2001 | Missing headers |
2002 | Invalid token |
2003 | Expired token |
2004 | Client access revoked |
2005 | Missing data |
2006 | Wrong data format |
2007 | Too many rows of data |
2008 | Incorrect user data |
/api2/reauthorizeToken refresh
Generate a new access token and refresh token. The access token returned on success is valid for 24 hours.
Headers
| Accept | application/app.fit2trade.v2 Required |
|---|---|
| Authorization | Bearer [Access Token] |
| Content-Type | application/json |
Request body
Supply a raw JSON object containing the required RefreshToken string.
{
"RefreshToken": "[refresh-token]"
}
Successful response
{
"Status": "OK",
"Error": { "ErrorCode": 0, "Message": "" },
"Data": {
"Token": "[new-access-token]",
"RefreshToken": "[new-refresh-token]"
}
}
/api2/usersCreate or update users
Create or modify users. The request body is a raw JSON array of objects; a single user must still be sent as a single-value array. The maximum request size is 100 users.
User properties
| Property | Value |
|---|---|
FirstName | String. Required for a new user. For an existing user, a supplied value updates the database; if blank, the current value remains unchanged. |
LastName | String. Same operation as FirstName. |
Email | String. Required. |
NewEmail | String. Required only when changing a user's email. The change fails if a user with the new email already exists. |
ExternalID | String. Used when IDs from the system accessing the API are required. |
LearnerRole | String. Optional. If a matching role definition is found, content is assigned according to the role. |
Location | Optional JSON object containing LocationID or ExternalID. If omitted, the user is created without a location and is prompted to select one on first login. If the object is present, one of the two IDs must be supplied or the location is ignored. External location IDs must be supplied before they are used through the API. |
AdminRole | Optional JSON object. If omitted, no admin rights are granted. IsAdmin is required; ViewOnly is optional and defaults to false. A valid Location must also be specified or the AdminRole is ignored. Setting IsAdmin to false revokes admin rights for the specified location. |
Sample request
[
{
"FirstName": "John",
"LastName": "Smith",
"Email": "john@fit2trade.com",
"LearnerRole": "sales",
"ExternalID": "HG76GHF"
},
{
"FirstName": "Barbara",
"LastName": "Jones",
"Email": "barbara@fit2trade.com",
"ExternalID": "LKHG5HK8",
"Location": {
"LocationID": null,
"ExternalID": null
},
"LearnerRole": "admin",
"AdminRole": {
"IsAdmin": true,
"ViewOnly": false,
"Location": {
"LocationID": null,
"ExternalID": null
}
}
}
]
Response
On success, Data contains a list of user IDs and email addresses. A UserID of 0 means that user was not successfully created or updated.
/api2/users/deactivateDeactivate users
Archive users. Send a JSON array containing up to 100 users. Email is required and ExternalID is optional. Users identified by email are archived; email addresses not found are ignored.
[
{ "Email": "john@fit2trade.com" },
{ "Email": "barbara@fit2trade.com", "ExternalID": "LKHG5HK8" }
]
UserID = -1User not found
UserID = 0User successfully archived
UserID > 0User not archived
/api2/users/reactivateReactivate users
Unarchive users. Send a JSON array containing up to 100 users. Email is required and ExternalID is optional.
[
{ "Email": "john@fit2trade.com" },
{ "Email": "barbara@fit2trade.com", "ExternalID": "LKHG5HK8" }
]
UserID = 0User was not reactivated
UserID > 0User successfully reactivated
/api2/users/completionsCourse completions
Get the list of courses completed by users. Send a JSON array containing up to 100 users; Email is required for each object.
[
{ "Email": "john@fit2trade.com" },
{ "Email": "barbara@fit2trade.com" }
]
Sample response
{
"Error": { "ErrorCode": 0, "Message": "" },
"Status": "OK",
"Data": [
{
"UserID": 1,
"Email": "john@fit2trade.com",
"Completions": [
{
"CourseID": 130,
"Course": "Word Skills",
"CompletionDate": "2023-12-31T00:00:00",
"CertExpiryDate": "2026-08-06T00:00:00"
}
]
}
]
}
/api2/users/credentialsUser credentials
Get a login token for a user. This token is valid for 5 minutes. The documented flow can be used to publish a link that signs a user into Fit2Trade automatically, provided the user's password in both applications is the same.
- Call
/api2/users/credentialsto obtain the 5-minute login token. - Use that token with
/api2/users/loginto obtain a new login token valid for 8 hours. - Use
[base_url]/api2/users/connect/[login_token]to access Fit2Trade without prompting the user to log in.
Request body
{
"Email": "john@fit2trade.com"
}
Sample response
{
"Error": { "ErrorCode": 0, "Message": "" },
"Status": "OK",
"Data": {
"Email": "john@fit2trade.com",
"LoginToken": "[5-minute-login-token]"
}
}
/api2/users/loginLogin user
Exchange the short-lived login token for a login token that is valid for 8 hours and can be used to create an access link to Fit2Trade without prompting the user to log in. The response also includes an Image property containing the Fit2Trade logo in SVG format.
Request body
| Property | Value |
|---|---|
Email | String. Required. |
LoginToken | String. Required. |
Password | String. Required. |
{
"Email": "john@fit2trade.com",
"LoginToken": "[5-minute-login-token]",
"Password": "[user-password]"
}
Sample response
{
"Error": { "ErrorCode": 0, "Message": "" },
"Status": "OK",
"Data": {
"Email": "john@fit2trade.com",
"LoginToken": "[8-hour-login-token]",
"Image": "<svg width="100%" height="100%"> … </svg>"
}
}
/api2/users/connect/[login_token]Access Fit2Trade
Use the 8-hour login token to access Fit2Trade without prompting the user to log in.
Headers
| Accept | application/app.fit2trade.v2 Required |
|---|---|
| Authorization | Bearer [Access Token] |
If successful, the user is taken to their landing page. If not, the user is presented with the login page.