# Issuing Token

The Issuing Token resource represents a tokenized version of a card stored in a digital wallet.

Tokens allow cardholders to make purchases using digital wallets without exposing the actual card number.

You can manage token status and monitor token activity through the log endpoints.

### The Issuing Token object

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `id` | STRING | Unique identifier for the issuing token. |
| `cardId` | STRING | Id of the IssuingCard this token is associated with. |
| `walletId` | STRING | Id of the digital wallet where the token is stored. |
| `walletName` | STRING | Name of the digital wallet. Example: "Apple Pay", "Google Pay". |
| `merchantId` | STRING | Id of the merchant if the token is merchant-specific. |
| `externalId` | STRING | Unique external identifier of the token. |
| `walletDeviceScore` | FLOAT | Device score informed by the digital wallet. |
| `walletAccountScore` | FLOAT | Account score informed by the digital wallet. |
| `status` | STRING | Current token status. Options: "active", "blocked", "canceled", "frozen", "pending", "denied". |
| `tags` | LIST OF STRINGS | Tags associated with the token. |
| `created` | STRING | Creation datetime. Example: "2022-01-01T00:00:00.000000+00:00". |
| `updated` | STRING | Last update datetime. Example: "2022-01-01T00:00:00.000000+00:00". |

### List Issuing Tokens

`GET /v2/issuing-token`

Get a list of issuing tokens in chunks of at most 100.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `limit` | OPTIONAL | Number of results per cursor. Max = 100. |
| `cursor` | OPTIONAL | String used to get the next batch of results. Our SDKs handle this for you. |
| `after` | OPTIONAL | Filter entities created after this date. |
| `before` | OPTIONAL | Filter entities created before this date. |
| `status` | OPTIONAL | Filter tokens by the specified status. |
| `cardIds` | OPTIONAL | Filter tokens by card ids. |
| `externalIds` | OPTIONAL | Filter tokens by external ids. |
| `tags` | OPTIONAL | Filter entities that contain the specified tags. |
| `ids` | OPTIONAL | List of strings to get specific entities by ids. |

**Request**

```python
import starkinfra

tokens = starkinfra.issuingtoken.query(
    limit=10,
    status="active"
)

for token in tokens:
    print(token)
```

**Response**

```python
IssuingToken(
    id=5715709195239424,
    card_id=6724771005489152,
    wallet_id=apple,
    wallet_name=Apple Pay,
    merchant_id=5656565656565656,
    external_id=DNITHE301234567890123456789012345678,
    wallet_device_score=None,
    wallet_account_score=None,
    status=active,
    tags=['department: tech'],
    created=2022-01-01 00:00:00,
    updated=2022-01-01 00:00:00
)
```

### Get an Issuing Token

`GET /v2/issuing-token/:id`

Get a single issuing token by its id.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `id` | REQUIRED | Id of the issuing token entity. |

**Request**

```python
import starkinfra

token = starkinfra.issuingtoken.get("5715709195239424")

print(token)
```

**Response**

```python
IssuingToken(
    id=5715709195239424,
    card_id=6724771005489152,
    wallet_id=apple,
    wallet_name=Apple Pay,
    merchant_id=5656565656565656,
    external_id=DNITHE301234567890123456789012345678,
    wallet_device_score=None,
    wallet_account_score=None,
    status=active,
    tags=['department: tech'],
    created=2022-01-01 00:00:00,
    updated=2022-01-01 00:00:00
)
```

### Update an Issuing Token

`PATCH /v2/issuing-token/:id`

Update the status or tags of an existing issuing token.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `id` | REQUIRED | Id of the issuing token entity. |
| `status` | OPTIONAL | Status to update the token to. Options: "active", "blocked". |
| `tags` | OPTIONAL | New array of strings to tag the token. |

**Request**

```python
import starkinfra

token = starkinfra.issuingtoken.update(
    "5715709195239424",
    status="blocked",
    tags=["blocked-reason: lost"]
)

print(token)
```

**Response**

```python
IssuingToken(
    id=5715709195239424,
    card_id=6724771005489152,
    wallet_id=apple,
    wallet_name=Apple Pay,
    merchant_id=5656565656565656,
    external_id=DNITHE301234567890123456789012345678,
    wallet_device_score=None,
    wallet_account_score=None,
    status=blocked,
    tags=['department: tech'],
    created=2022-01-01 00:00:00,
    updated=2022-06-01 00:00:00
)
```

### Cancel an Issuing Token

`DELETE /v2/issuing-token/:id`

Cancel an issuing token. This action is irreversible.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `id` | REQUIRED | Id of the issuing token entity to cancel. |

**Request**

```python
import starkinfra

token = starkinfra.issuingtoken.cancel("5715709195239424")

print(token)
```

**Response**

```python
IssuingToken(
    id=5715709195239424,
    card_id=6724771005489152,
    wallet_id=apple,
    wallet_name=Apple Pay,
    merchant_id=5656565656565656,
    external_id=DNITHE301234567890123456789012345678,
    wallet_device_score=None,
    wallet_account_score=None,
    status=canceled,
    tags=['department: tech'],
    created=2022-01-01 00:00:00,
    updated=2022-06-01 00:00:00
)
```

### List Issuing Token Logs

`GET /v2/issuing-token/log`

Get a paged list of issuing token logs.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `limit` | OPTIONAL | Number of results per cursor. Max = 100. |
| `cursor` | OPTIONAL | String used to get the next batch of results. Our SDKs handle this for you. |
| `after` | OPTIONAL | Filter entities created after this date. |
| `before` | OPTIONAL | Filter entities created before this date. |
| `types` | OPTIONAL | Filter logs by log types. |
| `tokenIds` | OPTIONAL | Array of token ids to filter logs. |
| `tokenTags` | OPTIONAL | Filter logs by the tags of their tokens. |

**Request**

```python
import starkinfra

logs = starkinfra.issuingtoken.log.query(
    limit=10,
    types=["created"]
)

for log in logs:
    print(log)
```

**Response**

```python
Log(
    id=6724771005489152,
    type=created,
    errors=[],
    token=IssuingToken(id=5715709195239424, status=active),
    created=2022-01-01 00:00:00
)
```

### Get an Issuing Token Log

`GET /v2/issuing-token/log/:id`

Get a single issuing token log by its id.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `id` | REQUIRED | Id of the log entity. |

**Request**

```python
import starkinfra

log = starkinfra.issuingtoken.log.get("6724771005489152")

print(log)
```

**Response**

```python
Log(
    id=6724771005489152,
    type=created,
    errors=[],
    token=IssuingToken(id=5715709195239424, status=active),
    created=2022-01-01 00:00:00
)
```

## Available Languages

Code samples on this page are in Python. The same content is available with samples in:

- [Python](https://docs.starkinfra.com/api/v2/issuing-token-python.md)
- [Node.js](https://docs.starkinfra.com/api/v2/issuing-token-node.md)
- [PHP](https://docs.starkinfra.com/api/v2/issuing-token-php.md)
- [Java](https://docs.starkinfra.com/api/v2/issuing-token-java.md)
- [Ruby](https://docs.starkinfra.com/api/v2/issuing-token-ruby.md)
- [Elixir](https://docs.starkinfra.com/api/v2/issuing-token-elixir.md)
- [.NET](https://docs.starkinfra.com/api/v2/issuing-token-dotnet.md)
- [Go](https://docs.starkinfra.com/api/v2/issuing-token-go.md)
- [Clojure](https://docs.starkinfra.com/api/v2/issuing-token-clojure.md)
- [cURL](https://docs.starkinfra.com/api/v2/issuing-token-curl.md)
