---
title: "send(ins:p1:p2:data:le:reply:)"
framework: cryptotokenkit
role: symbol
role_heading: Instance Method
path: "cryptotokenkit/tksmartcard/send(ins:p1:p2:data:le:reply:)"
---

# send(ins:p1:p2:data:le:reply:)

Asynchronously transmits an APDU command to the card, returning the response in a completion handler.

## Declaration

```swift
func send(ins: UInt8, p1: UInt8, p2: UInt8, data: Data? = nil, le: Int? = nil, reply: @escaping (Data?, UInt16, (any Error)?) -> Void)
```

## Parameters

- `ins`: The instruction code.
- `p1`: The first parameter.
- `p2`: The second parameter.
- `data`: The data field, or nil if no input data field is present—for example, a case1 or case2 APDU. The length of the data serves as Lc field of the APDU.
- `le`: The expected number of bytes to be returned, or nil if no output data are expected—for example, a case1 or case3 APDU. Pass 0 to accept as many bytes as the card provides.
- `reply`: A closure to call when the response is returned from the card.

## Discussion

Discussion This call handles all ISO7816-4 APDU cases, translating to proper the sequences according to the protocol.  It consults the useExtendedLength and useCommandChaining properties and uses these modes whenever appropriate for sending the APDU request.

## See Also

### Transmitting Data

- [withSession(_:)](cryptotokenkit/tksmartcard/withsession(_:).md)
