Skip to main content

Provision

Magistrala CLI provides provision commands to quickly set up clients, channels, and their connections. This guide covers bulk creation processes and a test setup for rapid development.

**NB:**Magistrala provides Sample files a user can user for bulk provisioning in the Magistrala UI Repository.

Provision Clients​

Bulk create multiple clients by providing a configuration file (JSON or CSV format) along with the required domain ID and user authentication token.

magistrala-cli provision clients <clients_file> <domain_id> <user_token>

Example usage:

magistrala-cli provision clients samples/clients.csv 9879f314-8b0a-4a11-b157-8523491ffa81 token

Expected Response:

[
{
"created_at": "2025-02-12T15:54:48.14268Z",
"credentials": {
"secret": "7f65b0e5-bf3c-41d9-bd8a-70263320b9ab"
},
"domain_id": "9879f314-8b0a-4a11-b157-8523491ffa81",
"id": "54d6e225-994b-4dcf-8487-58abc5557bd3",
"name": "Name",
"status": "enabled",
"updated_at": "0001-01-01T00:00:00Z"
},
{
"created_at": "2025-02-12T15:54:48.142684Z",
"credentials": {
"secret": "11b12a2d-739a-402b-bc9f-4d22d17c0e71"
},
"domain_id": "9879f314-8b0a-4a11-b157-8523491ffa81",
"id": "e5f96c45-f291-45f6-8bb7-5414186e48f7",
"name": "Client1",
"status": "enabled",
"updated_at": "0001-01-01T00:00:00Z"
},
{
"created_at": "2025-02-12T15:54:48.142689Z",
"credentials": {
"secret": "422891b4-ecd6-41d7-b53e-cbaf14591a73"
},
"domain_id": "9879f314-8b0a-4a11-b157-8523491ffa81",
"id": "5a5325b1-4d85-4584-82dd-d10d9420ae28",
"name": "Client2",
"status": "enabled",
"updated_at": "0001-01-01T00:00:00Z"
},
{
"created_at": "2025-02-12T15:54:48.142702Z",
"credentials": {
"secret": "a3731d94-20ad-47f9-bfb3-002b5243346f"
},
"domain_id": "9879f314-8b0a-4a11-b157-8523491ffa81",
"id": "84cfe076-bdf5-4851-bddc-fa2003b46c55",
"name": "Client3",
"status": "enabled",
"updated_at": "0001-01-01T00:00:00Z"
},
{
"created_at": "2025-02-12T15:54:48.142706Z",
"credentials": {
"secret": "5c186062-18d9-48af-95f1-80f6ef33cd42"
},
"domain_id": "9879f314-8b0a-4a11-b157-8523491ffa81",
"id": "caa036c2-adb0-4dfb-ad8f-6764119c00c9",
"name": "Client4",
"status": "enabled",
"updated_at": "0001-01-01T00:00:00Z"
},
{
"created_at": "2025-02-12T15:54:48.14271Z",
"credentials": {
"secret": "1f0edb94-2aff-4445-bb5f-2c12e90dcf40"
},
"domain_id": "9879f314-8b0a-4a11-b157-8523491ffa81",
"id": "22e7a472-d01c-4bf2-bd01-e6ba85515a66",
"name": "Client5",
"status": "enabled",
"updated_at": "0001-01-01T00:00:00Z"
},
{
"created_at": "2025-02-12T15:54:48.142714Z",
"credentials": {
"secret": "0a72104b-3664-4b47-82b8-fcbd70fef45a"
},
"domain_id": "9879f314-8b0a-4a11-b157-8523491ffa81",
"id": "3292b502-1c10-4f80-8de4-1d94e0334791",
"name": "Client6",
"status": "enabled",
"updated_at": "0001-01-01T00:00:00Z"
}
]

Provision Channels​

Bulk create channels using a configuration file with the domain ID and user token.

magistrala-cli provision channels <channels_file> <domain_id> <user_token>

Provision Connections​

Connect clients to channels in bulk using a connections file. This allows easy management of large IoT setups.

magistrala-cli provision connect <connections_file> <domain_id> <user_token>

Quick Test Setup​

The test command provisions a simple test environment, including:

  • One test user
  • Two clients
  • Two channels

The setup connects:

  • Both clients to one channel
  • One client to the second channel

Additionally, it sends test messages to verify connectivity.

🔍 Note: This is ideal for quick validations in development environments.

magistrala-cli provision test

ℹī¸ For more details on provisioning commands, run: magistrala-cli provision --help