Skip to content

Manage Users

Although the administrator users of the B2B site technically can manage user data directly in the WordPress admin area, the only approved way to manage users is from the Navision ERP via API. This ensures that the user data is always in sync with the data in the ERP system.

This API connects the Navision ERP and the B2B website. This means that any user related action is initiated from within the Navision ERP that communicates with the B2B portal via API.

API

The B2B site utilizes the WordPress REST API.

Accessing the API is only possible if the request is authenticated with a username and application password. The username and it’s application password can be passed along to REST API requests served over https:// using Basic Auth / RFC 7617.

Request / Response Format

The payload format is plain JSON and the standard HTTP verbs used for the requests.
Successful requests will return a 200 OK HTTP status.

Errors

Occasionally errors might occur when accessing the API. There are four possible types:

Error CodeError Type
400 Bad RequestInvalid request, e.g. using an unsupported HTTP method.
401 UnauthorizedAuthentication or permission error.
404 Not FoundRequests to resources that don’t exist or are missing.
500 Internal Server ErrorServer error

API error example:

{
"code": "rest_forbidden",
"message": "Sorry, you are not allowed to do that.",
"data": {
"status": 401
}
}

Available actions

The users API allows to create, update, and delete individual users.

Currently, the following actions are possible via the API:

Create User

Creation of a single user.

HTTP request

[POST] /wp-json/tcsgeu/v1/customers

JSON payload

KeyValueDescription
ContactNostringUser’s unique identifier in the Navision ERP. It is also used as a unique identifier of the user in the WordPress user database. Serves as the username for login to the users account.
NamestringUser’s name
EmailstringUser’s email address. Can be used interchangeably with the ContactNo as the username for login to the users account.
PhoneNostringUser’s phone number.
CustomerNostringThe company identifier - used for querying the price and stock information from the Navision API.
CompanyNamestringThe company name.

Example payload

{
"ContactNo":"CT000022",
"Name":"Mr. John Doe",
"Email":"[email protected]",
"PhoneNo":"+3611234567",
"CustomerNo":"01234567",
"CompanyName":"Company Name Ltd."
}

Example response for successful user creation:

{
"user_id": 18,
"user_login": "CT000022"
}

Modify User

Modify a single user.

HTTP request

[POST] /wp-json/tcsgeu/v1/customers/<ContactNo>

JSON payload

Currently, the following user data can be modified via the API:

KeyValueDescription
NamestringUser’s name
EmailstringUser’s email address.
PhoneNostringUser’s phone number

Example payload

{
"Name":"Mr. John Doe",
"Email":"[email protected]",
"PhoneNo":"+3611234567",
}

Example response

{
"user_id": 18,
"user_login": "CT000022"
}

Disable User

Disabling a single user.

While disabled the user can’t log in. Nothing is deleted from the account.

HTTP request

[POST] /wp-json/tcsgeu/v1/customers/disable

JSON payload

KeyValueDescription
ContactNostringUser’s unique identifier in the Navision ERP.

Example request

{
"ContactNo":"CT000022",
}

Example response

{
"user_id": 18,
"user_login": "CT000022"
}

Enable User

Enable a single user.

HTTP request

[POST] /wp-json/tcsgeu/v1/customers/enable

JSON payload

KeyValueDescription
ContactNostringUsers unique identifier in the Navision ERP.

Example request

{
"ContactNo":"CT000022",
}

Example response

{
"user_id": 18,
"user_login": "CT000022"
}

Delete User

Delete a single user.

HTTP request

[DELETE] /wp-json/tcsgeu/v1/customers/<ContactNo>

JSON payload

Currently, this action requires no payload.

Example response

{
"user_id": 18,
"user_login": "CT000022"
}