### Example GET Request for Device Activation Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-service.md An example of how to make a GET request to retrieve device activation details using the device EUI. ```http GET /api/devices/0102030405060708/activation ``` -------------------------------- ### Development Setup (Insecure) Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/configuration.md Example configuration for a development setup using command-line flags, including insecure gRPC and a wildcard CORS policy. ```bash chirpstack-rest-api \ --server localhost:8080 \ --bind 0.0.0.0:8090 \ --insecure \ --cors "*" ``` -------------------------------- ### Get Tenant Response Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/tenant-service.md Example of a successful response when retrieving tenant details, including tenant configuration and timestamps. ```json { "tenant": { "id": "customer-1", "name": "Customer 1", "description": "First customer", "canHaveGateways": true, "maxGatewayCount": 50, "maxDeviceCount": 5000, "createdAt": "2023-12-31T23:59:59Z", "updatedAt": "2023-12-31T23:59:59Z" } } ``` -------------------------------- ### Get Device Nonces Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-service.md Example GET request to retrieve used dev-nonces for a specific OTAA device. ```bash GET /api/devices/0102030405060708/dev-nonces ``` -------------------------------- ### Production Setup (TLS, Restricted CORS) Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/configuration.md Example configuration for a production setup using command-line flags, with TLS enabled by default and a restricted CORS policy. ```bash chirpstack-rest-api \ --server chirpstack-server:8080 \ --bind 0.0.0.0:8080 \ --cors "https://app.example.com,https://admin.example.com" ``` -------------------------------- ### Get Gateway Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/gateway-service.md Example of a GET request to retrieve details for a specific gateway using its ID. ```http GET /api/gateways/0102030405060708 ``` -------------------------------- ### Get Device Example Response Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-service.md An example of the JSON response when retrieving device details, including its status and last seen time. ```json { "device": { "devEui": "0102030405060708", "name": "Sensor-01", "applicationId": "weather-app", "deviceProfileId": "sensor-profile", "isDisabled": false, "isConnected": true, "lastSeenAt": "2023-12-31T23:59:59Z" } } ``` -------------------------------- ### List Gateways Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/gateway-service.md Example of how to list gateways with query parameters for filtering and pagination. ```http GET /api/gateways?tenantId=my-tenant&limit=50 ``` -------------------------------- ### Install ChirpStack REST API Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/README.md Download and install the ChirpStack REST API binary or use a package manager or Docker. ```bash curl -L https://artifacts.chirpstack.io/downloads/chirpstack-rest-api/latest -o chirpstack-rest-api chmod +x chirpstack-rest-api ``` ```bash sudo apt install chirpstack-rest-api ``` ```bash docker run -p 8090:8090 \ -e SERVER=localhost:8080 \ -e INSECURE=1 \ chirpstack/chirpstack-rest-api:latest ``` -------------------------------- ### Get Gateway Statistics Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/gateway-service.md Example of a GET request to retrieve statistics for a specific gateway. Replace '0102030405060708' with the actual gateway ID. ```bash GET /api/gateways/0102030405060708/stats ``` -------------------------------- ### Get Gateway Response Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/gateway-service.md Example JSON response when retrieving gateway details, including creation and update timestamps. ```json { "gateway": { "gatewayId": "0102030405060708", "tenantId": "my-tenant", "name": "Gateway 1", "description": "Office gateway", "location": { "latitude": 51.5074, "longitude": -0.1278 }, "tags": {"building": "A"}, "createdAt": "2023-12-31T23:59:59Z", "updatedAt": "2023-12-31T23:59:59Z" } } ``` -------------------------------- ### List Tenant Users Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/tenant-service.md GET request to list users within a specific tenant, with optional pagination parameters. ```http GET /api/tenants/customer-1/users?limit=20 ``` -------------------------------- ### Get Tenant User Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/tenant-service.md GET request to retrieve the roles of a specific user within a tenant. ```http GET /api/tenants/customer-1/users/john.doe ``` -------------------------------- ### Start ChirpStack REST API Server Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/README.md Start the ChirpStack REST API server with basic configuration, custom flags, or environment variables. ```bash ./chirpstack-rest-api ``` ```bash ./chirpstack-rest-api \ --server chirpstack.example.com:8080 \ --bind 0.0.0.0:8090 \ --cors "*" ``` ```bash export SERVER=chirpstack.example.com:8080 export BIND=0.0.0.0:8090 export CORS="*" ./chirpstack-rest-api ``` -------------------------------- ### Example Device Queue Response Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-service.md An example of the JSON response when retrieving pending queue items for a device. ```json { "queueItems": [ { "fPort": 10, "data": "SGVsbG8gV29ybGQ=", "isConfirmed": true, "isPending": true, "fcntDown": 51 } ] } ``` -------------------------------- ### Install ChirpStack REST API on Debian/Ubuntu Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/README.md Install the ChirpStack REST API component on Debian or Ubuntu systems after adding the ChirpStack repository. This command installs the pre-compiled package. ```bash sudo apt install chirpstack-rest-api ``` -------------------------------- ### Start ChirpStack REST API with Systemd Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/architecture.md This command starts the ChirpStack REST API as a systemd service. Configuration is typically located at /etc/chirpstack-rest-api/environment. ```bash sudo systemctl start chirpstack-rest-api # Config: /etc/chirpstack-rest-api/environment ``` -------------------------------- ### Start ChirpStack REST API Proxy Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/README.md Use this command to start the ChirpStack REST API proxy. Configure the gRPC server endpoint, bind address, TLS settings, and CORS policy using flags or environment variables. ```bash chirpstack-rest-api --server localhost:8080 --bind 0.0.0.0:8090 --insecure --cors "*" ``` -------------------------------- ### Create Gateway using cURL Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/gateway-service.md Example using cURL to send a POST request to create a gateway with basic information. ```bash curl -X POST http://localhost:8090/api/gateways \ -H "Content-Type: application/json" \ -d '{ "gateway": { "gatewayId": "0102030405060708", "tenantId": "my-tenant", "name": "Gateway 1", "location": { "latitude": 51.5074, "longitude": -0.1278 } } }' ``` -------------------------------- ### Setup HTTP Router with Gorilla Mux Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/architecture.md Sets up API routes using gRPC-Gateway and serves embedded UI assets. Route precedence is important for directing traffic correctly. ```go r := mux.NewRouter() // API routes (gRPC-Gateway handler) r.PathPrefix("/api/").Handler(gatewayHandler) // UI root r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { data, err := ui.FS.ReadFile("index.html") w.Write(data) }) // UI assets r.PathPrefix("/").Handler(http.FileServer(http.FS(ui.FS))) ``` -------------------------------- ### Create Tenant using cURL Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/tenant-service.md Example of creating a new tenant using a cURL command. Ensure the Content-Type header is set to application/json and the request body contains the tenant details. ```bash curl -X POST http://localhost:8090/api/tenants \ -H "Content-Type: application/json" \ -d '{ "tenant": { "id": "customer-1", "name": "Customer 1", "canHaveGateways": true, "maxDeviceCount": 5000 } }' ``` -------------------------------- ### Get Application Request Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/application-service.md Use this GET request to retrieve details for a specific application by providing its ID in the URL path. ```http GET /api/applications/weather-app ``` -------------------------------- ### Create Device using cURL Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-service.md Example of creating a new device using a cURL command. This includes setting the necessary headers and providing the device details in the request body. ```bash curl -X POST http://localhost:8090/api/devices \ -H "Content-Type: application/json" \ -d '{ "device": { "devEui": "0102030405060708", "name": "Sensor-01", "applicationId": "weather-app", "deviceProfileId": "sensor-profile" } }' ``` -------------------------------- ### 404 Not Found (NOT_FOUND) Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/errors.md This JSON indicates that the requested resource could not be found. Verify the provided identifier (e.g., DevEUI, ID) and ensure the resource exists. ```json { "code": 5, "message": "Not found: device with DevEUI '0102030405060708' does not exist" } ``` -------------------------------- ### Add User to Tenant Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/tenant-service.md POST request to add a user to a tenant with specified roles. Requires tenant ID and user details in the request body. User ID is mandatory. ```json { "tenantUser": { "userId": "john.doe", "isAdmin": false, "isDeviceAdmin": true, "isGatewayAdmin": true } } ``` ```bash curl -X POST http://localhost:8090/api/tenants/customer-1/users \ -H "Content-Type: application/json" \ -d '{ "tenantUser": { "userId": "john.doe", "isDeviceAdmin": true, "isGatewayAdmin": true } }' ``` -------------------------------- ### Get Application Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/application-service.md Retrieves the details of a specific application by its ID. ```APIDOC ## Get Application ### Description Retrieves the details of a specific application by its ID. ### Method GET ### Endpoint /api/applications/{application.id} ### Parameters #### Path Parameters - **application.id** (string) - Required - Application ID ### Response #### Success Response (200) - **application** (Application) - Full application object ### Response Example ```json { "application": { "id": "weather-app", "name": "Weather Monitoring", "description": "", "tenantId": "main-tenant", "tags": {"type": "weather"} } } ``` ``` -------------------------------- ### Get Application Response Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/application-service.md This JSON object contains the full details of a requested application, including its ID, name, description, tenant ID, and tags. ```json { "application": { "id": "weather-app", "name": "Weather Monitoring", "description": "", "tenantId": "main-tenant", "tags": {"type": "weather"} } } ``` -------------------------------- ### 403 Forbidden (PERMISSION_DENIED) Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/errors.md This JSON indicates that the authenticated user does not have the necessary permissions to perform the requested operation. Ensure the user has the required roles or privileges. ```json { "code": 7, "message": "Permission denied: user is not admin" } ``` -------------------------------- ### Docker Environment Variables Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/configuration.md Example of running ChirpStack REST API in a Docker container using environment variables for configuration. ```bash docker run -d \ -e SERVER=chirpstack-server:8080 \ -e BIND=0.0.0.0:8080 \ -e INSECURE=1 \ -e CORS="*" \ -p 8080:8080 \ chirpstack/chirpstack-rest-api ``` -------------------------------- ### List Applications via REST API Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/README.md Use curl to send a GET request to the /api/applications endpoint to list all applications. ```bash curl http://localhost:8090/api/applications ``` -------------------------------- ### CORS Configuration Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/endpoints.md Configure CORS origins using the --cors flag or CORS environment variable. Use '*' to allow all origins or specify comma-separated values for specific origins. ```bash --cors "*" ``` -------------------------------- ### Get Application Details Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/endpoints.md Retrieve details for a specific application using its ID in the URL path. ```http GET /api/applications/my-app ``` -------------------------------- ### Update Tenant using cURL Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/tenant-service.md Example of updating a tenant's configuration using a cURL command. Only fields provided in the request body will be updated. ```bash curl -X PUT http://localhost:8090/api/tenants/customer-1 \ -H "Content-Type: application/json" \ -d '{ "tenant": { "name": "Updated Customer Name", "maxDeviceCount": 10000 } }' ``` -------------------------------- ### 409 Conflict (ALREADY_EXISTS) Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/errors.md This JSON signifies an attempt to create a resource that already exists. Use a unique identifier or check for the resource's existence before creation. ```json { "code": 6, "message": "Already exists: application 'my-app' already exists" } ``` -------------------------------- ### Get Tenant Details Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/tenant-service.md Retrieve the details of a specific tenant by providing its ID in the URL path. Use this to view a tenant's full configuration. ```http GET /api/tenants/customer-1 ``` -------------------------------- ### Create Tenant and Application Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/README.md Use these commands to create a new tenant and then an application within that tenant. Subsequent resources like device profiles and devices will be associated with this tenant and application. ```bash # 1. Create tenant curl -X POST http://localhost:8090/api/tenants \ -H "Content-Type: application/json" \ -d '{"tenant": {"id": "customer-1", "name": "Customer 1"}}' # 2. Create application in tenant curl -X POST http://localhost:8090/api/applications \ -H "Content-Type: application/json" \ -d '{ "application": { "id": "app-1", "name": "Sensors", "tenantId": "customer-1" } }' # 3. Create device profile curl -X POST http://localhost:8090/api/device-profiles \ -H "Content-Type: application/json" \ -d '{ "deviceProfile": { "id": "profile-1", "name": "Sensor Profile", "tenantId": "customer-1", "region": "EU868", "macVersion": "1.0.4", "regParamsRevision": "B" } }' # 4. Create device curl -X POST http://localhost:8090/api/devices \ -H "Content-Type: application/json" \ -d '{ "device": { "devEui": "0102030405060708", "name": "Sensor 1", "applicationId": "app-1", "deviceProfileId": "profile-1" } }' ``` -------------------------------- ### Update Device Configuration using cURL Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-service.md Example of updating a device's configuration using a cURL command. Only the fields intended for modification need to be included in the request body. ```bash curl -X PUT http://localhost:8090/api/devices/0102030405060708 \ -H "Content-Type: application/json" \ -d '{ "device": { "name": "Updated Sensor Name", "isDisabled": false } }' ``` -------------------------------- ### Create Tenant and Application Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/README.md This workflow demonstrates how to create a new tenant, followed by an application within that tenant. It also includes steps for creating a device profile and a device associated with the application. ```APIDOC ## POST /api/tenants ### Description Creates a new tenant. ### Method POST ### Endpoint /api/tenants ### Request Body - **tenant** (object) - Required - Tenant object containing `id` and `name`. ### Request Example ```json { "tenant": { "id": "customer-1", "name": "Customer 1" } } ``` ## POST /api/applications ### Description Creates a new application within a tenant. ### Method POST ### Endpoint /api/applications ### Request Body - **application** (object) - Required - Application object containing `id`, `name`, and `tenantId`. ### Request Example ```json { "application": { "id": "app-1", "name": "Sensors", "tenantId": "customer-1" } } ``` ## POST /api/device-profiles ### Description Creates a new device profile. ### Method POST ### Endpoint /api/device-profiles ### Request Body - **deviceProfile** (object) - Required - Device profile object containing `id`, `name`, `tenantId`, `region`, `macVersion`, and `regParamsRevision`. ### Request Example ```json { "deviceProfile": { "id": "profile-1", "name": "Sensor Profile", "tenantId": "customer-1", "region": "EU868", "macVersion": "1.0.4", "regParamsRevision": "B" } } ``` ## POST /api/devices ### Description Creates a new device. ### Method POST ### Endpoint /api/devices ### Request Body - **device** (object) - Required - Device object containing `devEui`, `name`, `applicationId`, and `deviceProfileId`. ### Request Example ```json { "device": { "devEui": "0102030405060708", "name": "Sensor 1", "applicationId": "app-1", "deviceProfileId": "profile-1" } } ``` ``` -------------------------------- ### Create Application Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/endpoints.md Create a new application by sending a POST request with application details in the request body. The 'id', 'name', and 'tenantId' are required fields. ```http POST /api/applications Content-Type: application/json { "application": { "id": "my-app", "name": "My Application", "description": "Test application", "tenantId": "my-tenant", "tags": {"env": "dev"} } } ``` -------------------------------- ### Delete Gateway Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/gateway-service.md Example of a DELETE request to remove a gateway using its ID. ```http DELETE /api/gateways/0102030405060708 ``` -------------------------------- ### Create Application Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/endpoints.md Creates a new application with specified details including ID, name, description, tenant ID, and optional tags. ```APIDOC ## POST /api/applications ### Description Create a new application. ### Method POST ### Endpoint /api/applications ### Parameters #### Request Body - `application` (Application): Application object with fields: - `id` (string): Unique application ID - `name` (string): Human-readable name - `description` (string, optional): Application description - `tenantId` (string): Parent tenant ID - `tags` (map, optional): Key-value tags ### Request Example ``` POST /api/applications Content-Type: application/json { "application": { "id": "my-app", "name": "My Application", "description": "Test application", "tenantId": "my-tenant", "tags": {"env": "dev"} } } ``` ### Response #### Success Response (200) - `id` (string): Assigned application ID ``` -------------------------------- ### Build ChirpStack REST API from Source Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/README.md Commands for building the ChirpStack REST API from source using Make. Includes options for compiling the binary, creating distributable archives, and regenerating API definitions. ```bash make devshell ``` ```bash # Compile binary make build ``` ```bash # Create distributable archives and packages. make dist ``` ```bash # Create snapshot archives and packages. make snapshot ``` ```bash # Re-generate API definitions (VERSION must be set to the ChirpStack version) VERSION=v4.0.0 make generate ``` -------------------------------- ### Get User Details (GET /api/users/{id}) Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/user-service.md Retrieves details for a specific user by their ID. The response includes user information but not the password. ```http GET /api/users/john.doe ``` ```json { "user": { "id": "john.doe", "email": "john@example.com", "isActive": true, "isAdmin": false, "sessionTtl": 2592000, "createdAt": "2023-12-31T23:59:59Z", "updatedAt": "2023-12-31T23:59:59Z" } } ``` -------------------------------- ### Enqueue Downlink Request Body Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-service.md Example JSON structure for the request body when enqueuing a downlink message. The `isConfirmed` and `isPending` fields are optional. ```json { "queueItem": { "fPort": 10, "data": "SGVsbG8gV29ybGQ=", "isConfirmed": true, "isPending": false } } ``` -------------------------------- ### Error Handling Guide Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/COMPLETION-REPORT.txt A guide to understanding and handling errors returned by the ChirpStack REST API, including error codes, scenarios, and resolution strategies. ```APIDOC ## Error Handling - **gRPC code to HTTP status mapping**: Explains the translation of gRPC error codes to HTTP status codes. - **Condition that triggers each error**: Describes the circumstances leading to specific errors. - **How to detect error in code**: Provides guidance on identifying errors in client applications. - **How to fix the underlying issue**: Offers solutions for resolving the root causes of errors. - **Retry strategies**: Suggests strategies for retrying failed requests. ``` -------------------------------- ### Get Tenant Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/tenant-service.md Retrieves the details of a specific tenant by its ID. ```APIDOC ## GET /api/tenants/{id} ### Description Get tenant details. ### Method GET ### Endpoint /api/tenants/{id} ### Parameters #### Path Parameters - **id** (string) - Required - Tenant ID ### Response #### Success Response (200) - **tenant** (object) - Full Tenant object details ### Request Example ``` GET /api/tenants/customer-1 ``` ### Response Example ```json { "tenant": { "id": "customer-1", "name": "Customer 1", "description": "First customer", "canHaveGateways": true, "maxGatewayCount": 50, "maxDeviceCount": 5000, "createdAt": "2023-12-31T23:59:59Z", "updatedAt": "2023-12-31T23:59:59Z" } } ``` ``` -------------------------------- ### Create Tenant Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/tenant-service.md Creates a new tenant with specified details. ```APIDOC ## POST /api/tenants ### Description Create a new tenant. ### Method POST ### Endpoint /api/tenants ### Parameters #### Request Body - **tenant.id** (string) - Required - Unique tenant ID - **tenant.name** (string) - Required - Tenant name - **tenant.description** (string) - Optional - Description - **tenant.canHaveGateways** (bool) - Optional - Allow gateway ownership - **tenant.maxGatewayCount** (uint32) - Optional - Gateway quota (0 = unlimited) - **tenant.maxDeviceCount** (uint32) - Optional - Device quota (0 = unlimited) ### Request Example ```json { "tenant": { "id": "customer-1", "name": "Customer 1", "description": "First customer", "canHaveGateways": true, "maxGatewayCount": 50, "maxDeviceCount": 5000 } } ``` ### Response #### Success Response (200) - **assigned ID** (string) - The ID of the created tenant #### Status Codes - `200` — Created - `400` — Invalid request - `409` — Tenant ID exists ``` -------------------------------- ### Create Application Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/application-service.md Creates a new application with specified details. ```APIDOC ## Create Application ### Description Creates a new application with specified details. ### Method POST ### Endpoint /api/applications ### Parameters #### Request Body - **application** (Application) - Required - Application object - **application.id** (string) - Required - Unique application ID - **application.name** (string) - Required - Application name - **application.description** (string) - Optional - Description - **application.tenantId** (string) - Required - Parent tenant - **application.tags** (map) - Optional - Custom tags ### Request Example ```bash curl -X POST http://localhost:8090/api/applications \ -H "Content-Type: application/json" \ -d "{ "application": { "id": "weather-app", "name": "Weather Monitoring", "tenantId": "main-tenant", "tags": {"type": "weather"} } }" ``` ### Response #### Success Response (200) - **id** (string) - Created application ID ### Response Example ```json { "id": "weather-app" } ``` ``` -------------------------------- ### Get Gateway Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/gateway-service.md Retrieves the details of a specific gateway using its ID. ```APIDOC ## GET /api/gateways/{id} ### Description Get gateway details. ### Method GET ### Endpoint /api/gateways/{id} ### Parameters #### Path Parameters - **id** (string) - Required - Gateway ID (EUI) ### Response #### Success Response - **gateway** (Gateway object) - Full gateway details ### Request Example ``` GET /api/gateways/0102030405060708 ``` ### Response Example ```json { "gateway": { "gatewayId": "0102030405060708", "tenantId": "my-tenant", "name": "Gateway 1", "description": "Office gateway", "location": { "latitude": 51.5074, "longitude": -0.1278 }, "tags": {"building": "A"}, "createdAt": "2023-12-31T23:59:59Z", "updatedAt": "2023-12-31T23:59:59Z" } } ``` ``` -------------------------------- ### Remove User from Tenant Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/tenant-service.md DELETE request to remove a user from a tenant. ```http DELETE /api/tenants/customer-1/users/john.doe ``` -------------------------------- ### Get Multicast Group Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/multicast-group-service.md Retrieves the details of a specific multicast group by its ID. ```APIDOC ## GET /api/multicast-groups/{id} ### Description Retrieves the details of a specific multicast group by its ID. ### Method GET ### Endpoint /api/multicast-groups/{id} ### Parameters #### Path Parameters - **id** (string) - Required - Multicast group ID ### Response #### Success Response `GetMulticastGroupResponse` with full MulticastGroup object ### Request Example ``` GET /api/multicast-groups/fota-group ``` ``` -------------------------------- ### Create Application using cURL Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/application-service.md This cURL command demonstrates how to create a new application using a POST request. It includes the necessary headers and a JSON payload with application details. ```bash curl -X POST http://localhost:8090/api/applications \ -H "Content-Type: application/json" \ -d '{ "application": { "id": "weather-app", "name": "Weather Monitoring", "tenantId": "main-tenant", "tags": {"type": "weather"} } }' ``` -------------------------------- ### Get Multicast Group Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/multicast-group-service.md Retrieve the details of a specific multicast group by its ID. ```http GET /api/multicast-groups/fota-group ``` -------------------------------- ### Get Device Profile Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-profile-service.md Retrieves the details of a specific device profile by its ID. ```APIDOC ## Get Device Profile ### Description Retrieves the full details of a specific device profile using its unique identifier. ### Method GET ### Endpoint /api/device-profiles/{id} ### Parameters #### Path Parameters - **id** (string) - Required - Device profile ID ### Response #### Success Response (200) - **deviceProfile** (object) - The full device profile object ``` -------------------------------- ### Get Tenant User Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/tenant-service.md Retrieves the roles of a specific user within a tenant. ```APIDOC ## GET /api/tenants/{tenantId}/users/{userId} ### Description Get user roles in tenant. ### Method GET ### Endpoint /api/tenants/{tenantId}/users/{userId} #### Path Parameters - **tenantId** (string) - Required - Tenant ID - **userId** (string) - Required - User ID ### Response #### Success Response (200) - `GetTenantUserResponse` with TenantUser object ``` -------------------------------- ### Create Device Profile from Template Request Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-profile-template-service.md Example of how to create a device profile from a template using a curl command. Ensure the Content-Type header is set to application/json and the request body contains the template details. ```bash curl -X POST http://localhost:8090/api/device-profile-templates \ -H "Content-Type: application/json" \ -d '{ "deviceProfileTemplate": { "id": "my-template", "name": "My Custom Template", "region": "EU868", "macVersion": "1.0.4", "regParamsRevision": "B" } }' ``` -------------------------------- ### RFC3339 Timestamp Format Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/types.md All timestamps are represented in RFC3339 format with UTC timezone. ```text 2023-12-31T23:59:59Z ``` -------------------------------- ### Paginate List Endpoint Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/README.md Demonstrates how to paginate through list endpoints using 'limit' and 'offset' query parameters. Always paginate large result sets to avoid memory issues. ```bash # Get first 100 items curl "http://localhost:8090/api/devices?limit=100&offset=0" ``` ```bash # Get next 100 items curl "http://localhost:8090/api/devices?limit=100&offset=100" ``` -------------------------------- ### Get Device Profile Template Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-profile-template-service.md Retrieves the details of a specific device-profile template by its ID. ```APIDOC ## GET /api/device-profile-templates/{id} ### Description Gets device-profile template details. ### Method GET ### Endpoint /api/device-profile-templates/{id} #### Path Parameters - **id** (string) - Required - Template ID ### Response #### Success Response (200) - **GetDeviceProfileTemplateResponse** (object) - Contains the DeviceProfileTemplate object. ``` -------------------------------- ### Create Device Profile from Template Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-profile-template-service.md Create a new device profile by providing the details of a template. The request body must include a `deviceProfileTemplate` object with required fields like ID, name, region, MAC version, and regional parameters revision. ```json { "deviceProfileTemplate": { "id": "my-template", "name": "My Custom Template", "description": "Custom template for sensors", "vendor": "Custom", "region": "EU868", "macVersion": "1.0.4", "regParamsRevision": "B" } } ``` -------------------------------- ### Delete Device Request Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-service.md Example of deleting a device using its Device EUI. This operation is irreversible. ```http DELETE /api/devices/0102030405060708 ``` -------------------------------- ### List Applications Request Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/application-service.md Use this GET request to retrieve a list of applications. You can filter results by tenant ID and search by application name, and control pagination with limit and offset parameters. ```http GET /api/applications?limit=10&tenantId=my-tenant ``` -------------------------------- ### Get Device Queue Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-service.md Retrieves pending downlink messages in the device queue for a specific device. ```APIDOC ## GET /api/devices/{devEui}/queue ### Description Get pending downlink messages in device queue. ### Method GET ### Endpoint /api/devices/{devEui}/queue #### Path Parameters - **devEui** (string) - Required - Device EUI ### Response #### Success Response (200) - **queueItems** (DeviceQueueItem[]) - Pending queue items ### Response Example ```json { "queueItems": [ { "fPort": 10, "data": "SGVsbG8gV29ybGQ=", "isConfirmed": true, "isPending": true, "fcntDown": 51 } ] } ``` ``` -------------------------------- ### Get Device Details Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-service.md Retrieve the details of a specific device by providing its Device EUI in the URL path. ```http GET /api/devices/0102030405060708 ``` -------------------------------- ### Create Application Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/README.md Creates a new application within the ChirpStack network. ```APIDOC ## POST /api/applications ### Description Creates a new application. ### Method POST ### Endpoint /api/applications ### Parameters #### Request Body - **application** (object) - Required - The application object to create. - **id** (string) - Required - The unique identifier for the application. - **name** (string) - Required - The display name of the application. - **tenantId** (string) - Required - The ID of the tenant this application belongs to. ### Request Example { "example": "{\n \"application\": {\n \"id\": \"my-app\",\n \"name\": \"My Application\",\n \"tenantId\": \"my-tenant\"\n }\n}" } ``` -------------------------------- ### List Applications Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/application-service.md Retrieves a list of applications, with options for pagination, searching, and filtering by tenant ID. ```APIDOC ## List Applications ### Description Retrieves a list of applications, with options for pagination, searching, and filtering by tenant ID. ### Method GET ### Endpoint /api/applications ### Parameters #### Query Parameters - **limit** (int64) - Optional - Max items to return. If 0, returns count only. - **offset** (int64) - Optional - Items to skip (pagination offset) - **search** (string) - Optional - Search filter on application name - **tenantId** (string) - Optional - Filter by tenant ID ### Response #### Success Response (200) - **applications** (Application[]) - List of applications - **totalCount** (int64) - Total applications in system ### Response Example ```json { "applications": [ { "id": "app-1", "name": "Sensor Network", "description": "Building sensors", "tenantId": "my-tenant", "tags": {"building": "A"} } ], "totalCount": 42 } ``` ``` -------------------------------- ### Run ChirpStack REST API with Docker Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/architecture.md Use this command to run the ChirpStack REST API as a Docker container. Ensure the necessary environment variables are set. ```bash docker run -d \ -e SERVER=chirpstack:8080 \ -e BIND=0.0.0.0:8090 \ -e INSECURE=1 \ -p 8090:8090 \ chirpstack/chirpstack-rest-api:latest ``` -------------------------------- ### Get Device Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-service.md Retrieves the details of a specific device using its Device EUI. Includes activation, statistics, and connection status. ```APIDOC ## GET /api/devices/{devEui} ### Description Get device details. ### Method GET ### Endpoint /api/devices/{devEui} #### Path Parameters - **devEui** (string) - yes - Device EUI (16 hex chars) ### Response #### Success Response (200) - **device** (object) - Full Device object with activation, stats, and connection status ### Response Example ```json { "device": { "devEui": "0102030405060708", "name": "Sensor-01", "applicationId": "weather-app", "deviceProfileId": "sensor-profile", "isDisabled": false, "isConnected": true, "lastSeenAt": "2023-12-31T23:59:59Z" } } ``` ``` -------------------------------- ### Get User Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/user-service.md Retrieves the details of a specific user account using their ID. The response includes user information but not the password. ```APIDOC ## GET /api/users/{id} ### Description Get user details by their ID. Returns the full user object excluding the password. ### Method GET ### Endpoint /api/users/{id} ### Parameters #### Path Parameters - **id** (string) - Required - User ID (username) ### Response #### Success Response (200) - **user** (object) - Full user object including createdAt and updatedAt ### Response Example ```json { "user": { "id": "john.doe", "email": "john@example.com", "isActive": true, "isAdmin": false, "sessionTtl": 2592000, "createdAt": "2023-12-31T23:59:59Z", "updatedAt": "2023-12-31T23:59:59Z" } } ``` ``` -------------------------------- ### Create Device Profile using cURL Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-profile-service.md This cURL command demonstrates how to create a new device profile. It sends a POST request to the device-profiles endpoint with a JSON payload containing the profile's basic configuration. Note that only essential fields are included in this example. ```bash curl -X POST http://localhost:8090/api/device-profiles \ -H "Content-Type: application/json" \ -d '{ "deviceProfile": { "id": "sensor-profile", "tenantId": "my-tenant", "name": "Temperature Sensor", "region": "EU868", "macVersion": "1.0.4", "regParamsRevision": "B" } }' ``` -------------------------------- ### Get Device Profile Template Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-profile-template-service.md Retrieve the details of a specific device-profile template by providing its unique ID in the URL path. ```http GET /api/device-profile-templates/lora-class-a-otaa ``` -------------------------------- ### Create Device Profile from Template Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/device-profile-template-service.md Creates a new device profile based on a specified template. Requires a request body containing the template details. ```APIDOC ## POST /api/device-profile-templates ### Description Creates a device-profile from a template. ### Method POST ### Endpoint /api/device-profile-templates #### Request Body - **deviceProfileTemplate** (object) - Required - The template object to create the device profile from. - **id** (string) - Required - Unique template ID - **name** (string) - Required - Template name - **description** (string) - Optional - Description - **vendor** (string) - Optional - Vendor name - **region** (string) - Required - LoRaWAN region - **macVersion** (string) - Required - MAC version - **regParamsRevision** (string) - Required - Regional parameters revision ### Request Example { "deviceProfileTemplate": { "id": "my-template", "name": "My Custom Template", "description": "Custom template for sensors", "vendor": "Custom", "region": "EU868", "macVersion": "1.0.4", "regParamsRevision": "B" } } ### Response #### Success Response (200) - **CreateDeviceProfileTemplateResponse** (object) - Confirmation of creation. #### Error Responses - **400** — Invalid request - **409** — Template ID exists ``` -------------------------------- ### Update Gateway using cURL Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/gateway-service.md Example using cURL to send a PUT request to update a gateway's name and location. ```bash curl -X PUT http://localhost:8090/api/gateways/0102030405060708 \ -H "Content-Type: application/json" \ -d '{ "gateway": { "name": "Updated Gateway Name", "location": { "latitude": 51.5080, "longitude": -0.1290 } } }' ``` -------------------------------- ### List Applications Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/endpoints.md Retrieves a list of applications, with options for pagination, searching, and filtering by tenant ID. It returns the total count of applications matching the query. ```APIDOC ## GET /api/applications ### Description Get the list of applications. Supports filtering and pagination. ### Method GET ### Endpoint /api/applications ### Parameters #### Query Parameters - `limit` (int64, optional): Max number of applications to return. If 0, only returns total count. - `offset` (int64, optional): Offset in result-set for pagination. - `search` (string, optional): Search by application name. - `tenantId` (string, optional): Filter by tenant ID. ### Response #### Success Response (200) - `applications` (Application[]): Array of application objects - `totalCount` (int64): Total number of applications matching query ### Request Example ``` GET /api/applications?limit=10&offset=0&tenantId=my-tenant ``` ``` -------------------------------- ### Update Tenant User Roles Example Source: https://github.com/chirpstack/chirpstack-rest-api/blob/master/_autodocs/api-reference/tenant-service.md PUT request to update a user's roles within a tenant. Only role fields can be updated. ```bash curl -X PUT http://localhost:8090/api/tenants/customer-1/users/john.doe \ -H "Content-Type: application/json" \ -d '{ "tenantUser": { "isDeviceAdmin": false, "isGatewayAdmin": true } }' ```