Module Identifier: tokens
The tokens module gives CPOs knowledge of the token information of an eMSP. eMSPs can push Token information to CPOs, CPOs can build a cache of known Tokens. When a request to authorize comes from a Charge Point, the CPO can check against this cache. They then know to which eMSP they can later send a CDR.
When the MSP creates a new Token object they push it to the CPO by calling PUT on the CPOs Tokens endpoint with the newly create Token object.
Any changes to Token in the eMSP system are send to the CPO system by calling, either the PUT or the PATCH on the CPOs Tokens endpoint with the updated Token(s).
When the eMSP invalidates a Token (deleting is not possible), the eMSP will send the updated Token (with the field: valid set to False, by calling, either the PUT or the PATCH on the CPOs Tokens endpoint with the updated Token.
When the eMSP not sure about the state or existence of a Token object in the CPO system, the eMSP can call the GET to validate the Token object in the CPO system.
When a CPO is not sure about the state of the list of known Tokens, or wants to request the full list at start-up of their system, the CPO can call the GET on the eMSPs Token endpoint to receive all Tokens, updating already known Tokens and adding new received Tokens to it own list of Tokens. This method is not for operational flow.
There is both a CPO and an eMSP interface for Tokens. Advised is to use the push direction from eMSP to CPO during normal operation. The eMSP interface is mend to be used when the CPO is not 100% sure the Token cache is correct any more.
With this interface the eMSP can push the Token information to the CPO.
Tokens is a client owned object, so the end-points need to contain the required extra fields: {party_id} and {country_code}.
Example endpoint structure:
/ocpi/cpo/2.0/tokens/{country_code}/{party_id}/{token_uid}
If the eMSP wants to check the status of a Token in the CPO system it might GET the object from the CPO system for validation purposes. The eMSP is the owner of the objects, so it would be illogical if the CPO system had a different status of was missing an object.
| Parameter | Datatype | Required | Description | |---------------|---------------------------------------|----------|-------------------------------------------------------------------------------| | country_code | [string](types.md#16-string-type)(2) | yes | Country code of the CPO requesting this PUT to the eMSP system. | | party_id | [string](types.md#16-string-type)(3) | yes | Party ID (Provider ID) of the CPO requesting this PUT to the eMSP system. | | token_uid | [string](types.md#16-string-type)(15) | yes | Token.uid of the Token object to retrieve. |The response contains the requested object.
| Type | Card. | Description | |-------------------------------------|-------|------------------------------------------------------------| | [Token](#31-token-object) | 1 | The requested Token object. |New or updated Token objects are pushed from the CPO to the eMSP.
In the put request a the new or updated Token object is send.
| Type | Card. | Description | |---------------------------------|-------|------------------------------------------| | [Token](#31-token-object) | 1 | New or updated Tariff object. | | Parameter | Datatype | Required | Description | |---------------|---------------------------------------|----------|-------------------------------------------------------------------------------| | country_code | [string](types.md#16-string-type)(2) | yes | Country code of the CPO requesting this PUT to the eMSP system. | | party_id | [string](types.md#16-string-type)(3) | yes | Party ID (Provider ID) of the CPO requesting this PUT to the eMSP system. | | token_uid | [string](types.md#16-string-type)(15) | yes | Token.uid of the (new) Token object (to replace). |PUT To URL: https://www.server.com/ocpi/cpo/2.0/tokens/NL/TNM/012345678
{
"uid": "012345678",
"type": "RFID",
"auth_id": "FA54320",
"visual_number": "DF000-2001-8999",
"issuer": "TheNewMotion",
"valid": true,
"allow_whitelist": true
}
Same as the PUT method, but only the fields/objects that have to be updated have to be present, other fields/objects that are not specified are considered unchanged.
PATCH To URL: https://www.server.com/ocpi/cpo/2.0/tokens/NL/TNM/012345678
{
"valid": false
}
This interface enables the CPO to request the current list of all Tokens, when needed. It is not possible to validate/request a single token, during normal operation the Token cache of the CPO should always be kept up to date via the CPO Interface.
Example endpoint structure: /ocpi/emsp/2.0/tokens/
Fetch information about all Tokens known in the eMSP systems.
This request is paginated, it supports the pagination related URL parameters.
| Parameter | Datatype | Required | Description | |------------|---------------------------------------|----------|-------------------------------------------------------------------------------| | offset | int | no | The offset of the first object returned. Default is 0. | | limit | int | no | Maximum number of objects to GET. |The endpoint response with list of valid Token objects, the header will contain the pagination related headers.
Any older information that is not specified in the response is considered as no longer valid. Each object must contain all required fields. Fields that are not specified may be considered as null values.
| Type | Card. | Description | |---------------------------------|-------|------------------------------------------| | [Token](#31-token-object) | * | List of all tokens. | | Property | Type | Card. | Description | |-------------------------|---------------------------------------|-------|---------------------------------------------------------------------------------------------------------| | uid | [string](types.md#16-string-type)(15) | 1 | Identification used by CPO system to identify this token, for example RFID hidden ID | | type | [TokenType](#41-tokentype) | 1 | Type of the token | | auth_id | [string](types.md#16-string-type)(32) | 1 | Uniquely identifies the EV Driver contract token within the eMSPs platform (and suboperator platforms). | | visual_number | [string](types.md#16-string-type)(64) | 1 | Visual readable number/identification of the Token | | issuer | [string](types.md#16-string-type)(64) | 1 | Issuing company | | valid | boolean | 1 | Is this Token valid | | allow_whitelist | boolean | ? | It is allowed to validate a charging session with token without requesting and authorization from the eMSP? , default is FALSE. NOTE: For this release this field always needs to be set to TRUE |The combination of uid and type should be unique for every token.
{
"uid": "012345678",
"type": "RFID",
"auth_id": "FA54320",
"visual_number": "DF000-2001-8999",
"issuer": "TheNewMotion",
"valid": true,
"allow_whitelist": true
}