Overspeed configuration

Setting Overspeed Thresholds & Duration via GraphQL

This guide explains how to configure the speed limit thresholds and duration settings for a device using the journey_post_device_configs mutation.

Overview

To control how a device detects and reports overspeed events, you send an input whose attributes (see mutationInput_post_device_configs_input_data_attributes_Input) contain the device identifier and three overspeed parameters.

API endpoint

The mutation is available on the GraphQL Gateway at https://api.munic.io/services/graphql_gateway. Requests must include your Bearer token in the Authorization header.

Authentication

Provide your auth token in the Authorization: Bearer <token> HTTP header. See the auth service to obtain a token.

For full mutation details, see the GraphQL Gateway mutation reference.

Updating device config with the mutation

Use the journey_post_device_configs mutation to update the device configuration. The mutation takes an input whose data.attributes object contains the device imei and the three overspeed fields (all in the same attributes object, as per the attributes input type).

Update Journey device config (overspeed)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Variables:
 
{
  "input": {
    "data": {
      "type": "device_configs",
      "attributes": {
        "imei": "YOUR_DEVICE_IMEI",
        "speed_limit_exceeded_threshold": 40,
        "overspeed_min_duration": 10,
        "underspeed_max_duration": 5
      }
    }
  }
}

"""
mutation UpdateJourneyConfig($input: device_config_create_Input) {
  journey_post_device_configs(input: $input) {
    ... on device_config_show {
      data {
        id
        type
        attributes
      }
    }
    ... on errors {
      errors {
        title
        detail
      }
    }
  }
}
1
2
3
4
5
6
export TOKEN=<YOUR_MUNIC_CONNECT_TOKEN>

curl --request POST 'https://api.munic.io/services/ekko/v2/graphql' \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/json" \
--data '{"query": "mutation UpdateJourneyConfig($input: device_config_create_Input) {\n  journey_post_device_configs(input: $input) {\n    ... on device_config_show {\n      data {\n        id\n        type\n        attributes\n      }\n    }\n    ... on errors {\n      errors {\n        title\n        detail\n      }\n    }\n  }\n}", "variables":{  "input": {    "data": {      "type": "device_configs",      "attributes": {        "imei": "YOUR_DEVICE_IMEI",        "speed_limit_exceeded_threshold": 40,        "overspeed_min_duration": 10,        "underspeed_max_duration": 5      }    }  }}}'
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import requests

token = <YOUR_MUNIC_CONNECT_TOKEN>
url = "https://api.munic.io/services/ekko/v2/graphql"

payload = """
{"query": "mutation UpdateJourneyConfig($input: device_config_create_Input) {
  journey_post_device_configs(input: $input) {
    ... on device_config_show {
      data {
        id
        type
        attributes
      }
    }
    ... on errors {
      errors {
        title
        detail
      }
    }
  }
}", "variables":
{
  "input": {
    "data": {
      "type": "device_configs",
      "attributes": {
        "imei": "YOUR_DEVICE_IMEI",
        "speed_limit_exceeded_threshold": 40,
        "overspeed_min_duration": 10,
        "underspeed_max_duration": 5
      }
    }
  }
}
}
"""

payload = payload.replace("\n", "")

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer %s'%(token)
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Field definitions (input.data.attributes)

All fields below belong to the attributes object (input.data.attributes) of the mutation input:

FieldTypeUnitDescription
imeiIDDevice IMEI. Transmitted as string in JSON.
speed_limit_exceeded_thresholdFloatkm/hThe threshold added to the current speed limit that, when exceeded, triggers an overspeed alert (default is 8 km/h).
overspeed_min_durationIntegerSecondsThe minimum time the vehicle must stay above the thresholdto register as an overspeed event (default is 5s).
underspeed_max_durationIntegerSecondsThe maximum time allowed below the threshold before the event is considered “finished” (default is 5s).

Example with cURL

Replace YOUR_ACCESS_TOKEN with your actual Bearer token.

curl -X POST https://api.munic.io/services/graphql_gateway/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -d '{
    "query": "mutation($input: device_config_create_Input) { journey_post_device_configs(input: $input) { ... on device_config_show { data { id type attributes { imei speed_limit_exceeded_threshold } } } ... on errors { errors { title detail status } } } }",
    "variables": {
      "input": {
        "data": {
          "type": "device_configs",
          "attributes": {
            "imei": "123456789012345",
            "speed_limit_exceeded_threshold": 40,
            "overspeed_min_duration": 15,
            "underspeed_max_duration": 3
          }
        }
      }
    }
  }'

Expected response

Success: the API returns the created/updated device config under data (with id, type, and attributes).

See JSON success response
{
  "data": {
    "journey_post_device_configs": {
      "data": {
        "id": "123",
        "type": "device_configs",
        "attributes": {
          "imei": "123456789012345",
          "speed_limit_exceeded_threshold": 40,
          "overspeed_min_duration": 15,
          "underspeed_max_duration": 3
        }
      }
    }
  }
}

Error: on failure, journey_post_device_configs contains an errors array with objects exposing title and detail.

See JSON error response
{
  "data": {
    "journey_post_device_configs": {
      "errors": [
        { "title": "Validation error", "detail": "Invalid device or parameters" }
      ]
    }
  }
}