---
title: "Set PIN"
method: POST
path: "/v2/{plasticId}"
tags: ["PIN operations with pre-shared key"]
---

# Set PIN

`POST /v2/{plasticId}`

This operation sets PIN with encrypted PIN block in ISO format 1. The PIN block is encrypted using a pre-shared
double-length 3DES key.

#### Example
    // PIN 1234 in ISO format 1
    var pinBlock = "141234AAAAAAAAAA";
    // pre-shared zpk
    var zpk = Hex.decode("00112233445566778899AABBCCDDEEFF0011223344556677");
    // encrypt pinBlock with zpk
    var des = Cipher.getInstance("DESede/ECB/NoPadding");
    des.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(zpk, "DESede"));
    var encryptedPinBlock = Hex.toHexString(des.doFinal(Hex.decode(pinBlock)));
    // make request
    pinApiClient.post()
            .uri("/pin/v2/{plasticId}?auditUser={user}", 123456, "test")
            .bodyValue(Map.of(
                    "zpkIndex", "0",
                    "pinBlock", encryptedPinBlock
            ))
            .retrieve()
            .bodyToMono(Object.class)
            .block();

## Path parameters

- `plasticId` string, biginteger, required

## Query parameters

- `auditUser` string, required

## Request body

- PinBlockRequest
  - `zpkIndex` string, required — The PIN encryption key (ZPK) index. This index is used to point out which key to use in case there are multiple keys available.
  - `pinBlock` string, required — ISO format 1 PIN block 3DES encrypted with PIN encryption key in hexadecimal.

## Response `200`

PIN set successfully

- SetPinResponse

## Other responses

- `401` — Unauthorized
- `403` — Forbidden
- `404` — Card does not exist
- `500` — Internal server error

---

[API](https://skmtc.net/enfuce/apis/transfer-api.md) · [All operations](https://skmtc.net/enfuce/apis/transfer-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/enfuce/transfer-api/revisions/dc4a41118f80/schema)
