<!--
{
  "availability" : [
    "iOS: 18.4.0 -",
    "iPadOS: 18.4.0 -",
    "macCatalyst: 18.4.0 -",
    "macOS: 15.4.0 -",
    "tvOS: 18.4.0 -",
    "visionOS: 2.4.0 -",
    "watchOS: 11.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Matter",
  "identifier" : "/documentation/Matter/MTRDevice/invokeCommands(_:queue:completion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Matter"
    ],
    "preciseIdentifier" : "c:objc(cs)MTRDevice(im)invokeCommands:queue:completion:"
  },
  "title" : "invokeCommands(_:queue:completion:)"
}
-->

# invokeCommands(_:queue:completion:)

Invoke one or more groups of commands.

```
func invokeCommands(_ commands: [[MTRCommandWithRequiredResponse]], queue: dispatch_queue_t, completion: @escaping @Sendable ([[String : Any]]?, (any Error)?) -> Void)
```

```
func invokeCommands(_ commands: [[MTRCommandWithRequiredResponse]], queue: dispatch_queue_t) async throws -> [[String : Any]]
```

## Discussion

For any given group, if any command in any preceding group failed, the group
will be skipped.  If all commands in all preceding groups succeeded, the
commands within the group will be invoked, with no ordering guarantees within
that group.

Results from all commands that were invoked will be passed to the provided
completion as an array of response-value dictionaries.  Each of these will
have the command path of the command (see MTRCommandPathKey) and one of three
things:

1. No other fields, indicating that the command invoke returned a succcess
   status.
2. A field for MTRErrorKey, indicating that the invoke returned a failure
   status (which is the value of the field).
3. A field for MTRDataKey, indicating that the invoke returned a data
   response.  In this case the data-value representing the response will be
   the value of this field.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)