Training Tokens

Training Tokens are pre-set vouchers that can be redeemed for training at a later date. Essentially they work as another unit of currency.

For an introduction about the feature and the possibilities it unlocks, see our Support Documentation.

Training Token Types

In order to use tokens, Training Token Types have to be configured in the TMS so that they can be issued to specific Accounts.

Search

The following fetches the first page of the Training Token Types configured in the system:

Example

query {
  trainingTokenTypes{
    edges{
      node{
        id 
        name
        isArchived
        defaultDaysToRedeem
      }
    }
  }
}

Example response

{
  "data": {
    "trainingTokenTypes": {
      "edges": [
        {
          "node": {
            "id": "VG9rZW5UeXBlOjg4NDhhM2IzOGFkZjQ1ZGI4ZmY2MGZhZmNiZDNiM2Y2",
            "name": "Silver token",
            "isArchived": false,
            "defaultDaysToRedeem": 90
          }
        }
      ]
    }
  }
}

Issuing tokens

Given a token type, tokens can be issued to an account:

Example

mutation{
  trainingTokenIssues{
    create(input:{
      tokenTypeId: "VG9rZW5UeXBlOjg4NDhhM2IzOGFkZjQ1ZGI4ZmY2MGZhZmNiZDNiM2Y2"
      accountId: "T3JnYW5pc2F0aW9uOjI="
      quantity: 100
    }) {
      errors{
        label
        message 
        value
        }
      tokenIssue{
        id
        createdAt
        currentBalance
        tokenAccount{
          account{
            name
          }
        }
      }
    }
  }
}

The response confirms 100 tokens have been issued to the chosen account:

{
  "data": {
    "trainingTokenIssues": {
      "create": {
        "errors": [],
        "tokenIssue": {
          "id": "VG9rZW5Jc3N1ZTozN2U3ODgzZDFjOWQ0NzFmYjhlYWJkNGExMTM4ZGNlOA==",
          "createdAt": "2023-04-04T08:41:30Z",
          "currentBalance": 100,
          "tokenAccount": {
            "account": {
              "name": "Administrate"
            }
          }
        }
      }
    }
  }
}

For all options that can be specified when issuing tokens, see our TokenIssueCreateInput API Reference.

Extend validity

The expiry of previously issued tokens can be extended:

Example

mutation{
  trainingTokenIssues{
    extend(input:{
      tokenIssueId: "VG9rZW5Jc3N1ZTozN2U3ODgzZDFjOWQ0NzFmYjhlYWJkNGExMTM4ZGNlOA=="
      expiresAt: "2023-12-31"
    }) {
      errors{
        label
        message 
        value
        }
      tokenIssue{
        id
        expiresAt
      }
    }
  }
}

The response confirms the new expiry:

{
  "data": {
    "trainingTokenIssues": {
      "extend": {
        "errors": [],
        "tokenIssue": {
          "id": "VG9rZW5Jc3N1ZTozN2U3ODgzZDFjOWQ0NzFmYjhlYWJkNGExMTM4ZGNlOA==",
          "expiresAt": "2023-12-31T23:59:59Z"
        }
      }
    }
  }
}

Manual adjustments

Training Token balances can be manually adjusted to add or remove tokens from an issue:

Example

mutation{
  trainingTokenBalances{
    adjust(input:{
      tokenIssueId: "VG9rZW5Jc3N1ZTozN2U3ODgzZDFjOWQ0NzFmYjhlYWJkNGExMTM4ZGNlOA=="
      amount: 200
      notes: "Manual adjustment"
    }) {
      errors{
        label
        message 
        value
        }
      tokenIssue{
        id
        currentBalance
        initialBalance
        transactions{
          edges{
            node{
              occurredAt
              notes
              balanceDelta

            }
          }
        }
      }
    }
  }
}

Given an initial balance of a 100, the response shows the new balance of 300 following the adjustment. The transactions field also shows details of the adjustment:

{
  "data": {
    "trainingTokenBalances": {
      "adjust": {
        "errors": [],
        "tokenIssue": {
          "id": "VG9rZW5Jc3N1ZTozN2U3ODgzZDFjOWQ0NzFmYjhlYWJkNGExMTM4ZGNlOA==",
          "currentBalance": 300,
          "initialBalance": 100,
          "transactions": {
            "edges": [
              {
                "node": {
                  "occurredAt": "2023-04-04T08:41:30Z",
                  "notes": "",
                  "balanceDelta": 100
                }
              },
              {
                "node": {
                  "occurredAt": "2023-04-04T08:48:23Z",
                  "notes": "Manual adjustment",
                  "balanceDelta": 200
                }
              }
            ]
          }
        }
      }
    }
  }
}