> For the complete documentation index, see [llms.txt](https://docs.racemap.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.racemap.com/tracker-management/messages.md). Agents can also search and read this documentation through its [MCP server](https://docs.racemap.com/~gitbook/mcp).

# Send messages

Use the tracker management to efficiently send commands to multiple GPS trackers at once. You can even schedule commands for a specific time frame.

{% hint style="success" %}
Contact us, when missing a specific message you want to apply to your devices. You can also compose your own message templates.
{% endhint %}

### Messaging through API <a href="#trackers-api" id="trackers-api"></a>

Independent from sending [commands through the UI of the tracker management](https://docs.racemap.com/tracker-management/messages.md) dashboard you can use message templates to integrate command sending into your system, e.g. to automate your processes.

* Send a `POST` request with an [API token](https://docs.racemap.com/api/authentication.md) of your account.
* **Sample message template** - Set report interval - for Queclink GL3xx GPS trackers:\
  <https://racemap.com/admin/message-templates/6613c31ad019cb0ece29e251>
* Get the required tracker ids from the `deviceId` of the `device` object in the [\*/current API](https://docs.racemap.com/api/current.md).

## Send a message template to trackers

> Creates one message per tracker from a message template and queues it for delivery. A group\
> template creates one message per sub-template whose tracker types include the tracker's type.\
> A single template whose tracker types do not include the tracker's type creates no message\
> and no error for that tracker.\
> \
> \- The caller MUST be allowed to read the template.\
> \- For each tracker, the caller MUST hold a role the template allows (owner, editor or\
> &#x20; borrower). Admins may send to any tracker.\
> \- A message whose reply carries no response id is sent once: \`maxNumOfAttempts\` becomes \`1\`.\
> \- Sending a message activates a tracker that is not paid yet for a billing cycle.\
> \
> Trackers are processed in order. An unknown tracker id or a missing role aborts the request\
> with \`404\` or \`401\`, but messages created for earlier trackers are kept. A failure while\
> saving one message is reported in \`errors\` instead.\
> \
> The same operation is also served at \`/api/trackers/messages\`.

```json
{"openapi":"3.1.0","info":{"title":"Racemap API v1","version":"1"},"tags":[{"name":"Tracker messages","description":"Send commands to GPS trackers in the tracker management, based on message templates."}],"servers":[{"url":"https://racemap.com"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"An API token of your Racemap account, sent as `Authorization: Bearer <API_TOKEN>`. Create\ntokens in the API Tokens section of your account settings."}},"schemas":{"TrackerMessagesRequest":{"type":"object","required":["templateId","trackerIds","parameters"],"properties":{"templateId":{"allOf":[{"$ref":"#/components/schemas/ObjectId"}],"description":"Id of the message template, shown in the message dashboard."},"trackerIds":{"type":"array","description":"Racemap ids of the trackers. The `deviceId` of the `device` object in the current\nresponse is such an id.","items":{"$ref":"#/components/schemas/ObjectId"}},"parameters":{"type":"object","description":"Values for the template's arguments, by argument name.","additionalProperties":{"type":"string"}},"transport":{"type":"string","enum":["tcp","sms"],"default":"tcp","description":"Channel to send the message over."},"plannedAt":{"type":"string","format":"date-time","description":"Earliest time to send the message. Defaults to now. A number of milliseconds since the\nepoch is accepted too."},"closeAfter":{"type":"string","format":"date-time","description":"Time after which the message is no longer sent. Defaults to seven days after creation. A\nnumber of milliseconds since the epoch is accepted too."},"maxNumOfAttempts":{"type":"integer","default":3,"description":"Maximum number of send attempts."}}},"ObjectId":{"type":"string","description":"12-byte ObjectId as 24-character hexadecimal string.","pattern":"^[0-9a-fA-F]{24}$"},"TrackerMessagesResponse":{"type":"object","required":["success","messages","errors"],"properties":{"success":{"type":"boolean","description":"`true` if every message was saved."},"messages":{"type":"array","items":{"$ref":"#/components/schemas/TrackerMessage"}},"errors":{"type":"array","items":{"$ref":"#/components/schemas/TrackerMessageError"}}}},"TrackerMessage":{"type":"object","required":["id","payload","templateId","label","createdAt","updatedAt","plannedAt","closeAfter","maxNumOfAttempts","trackerId","creatorId","responseId","transport","historyRecords","shouldAck","events"],"properties":{"id":{"$ref":"#/components/schemas/ObjectId"},"payload":{"type":"object","description":"The command sent to the tracker, as a serialized Node.js Buffer.","required":["type","data"],"properties":{"type":{"type":"string","const":"Buffer"},"data":{"type":"array","description":"Bytes of the command.","items":{"type":"integer","minimum":0,"maximum":255}}}},"templateId":{"allOf":[{"$ref":"#/components/schemas/ObjectId"}],"description":"Id of the (sub-)template the message was built from."},"parameters":{"type":"object","description":"The parameters of the request.","additionalProperties":{"type":"string"}},"label":{"type":"string","description":"Name of the template."},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"plannedAt":{"type":"string","format":"date-time"},"closeAfter":{"type":"string","format":"date-time"},"maxNumOfAttempts":{"type":"integer"},"trackerId":{"$ref":"#/components/schemas/ObjectId"},"creatorId":{"allOf":[{"$ref":"#/components/schemas/ObjectId"}],"description":"Id of the user who sent the message."},"responseId":{"type":["string","null"],"description":"Id the tracker's reply is matched by. `null` if the reply cannot be matched."},"transport":{"type":"string","enum":["tcp","sms"]},"historyRecords":{"type":"array","description":"Always empty in this response.","maxItems":0,"items":{}},"shouldAck":{"type":"boolean","description":"Whether the tracker type acknowledges messages."},"events":{"type":"array","description":"Entity events of the message. Empty for a new message.","items":{"type":"object"}}}},"TrackerMessageError":{"type":"object","required":["message","trackerId","templateId"],"properties":{"message":{"type":"string","description":"Why the message could not be saved."},"trackerId":{"$ref":"#/components/schemas/ObjectId"},"templateId":{"$ref":"#/components/schemas/ObjectId"}}},"StatusError":{"type":"object","description":"Error body of the tracker message endpoint.","required":["status"],"properties":{"status":{"type":"string","description":"Error message."}}}}},"paths":{"/api/v1/trackers/messages":{"post":{"tags":["Tracker messages"],"operationId":"createTrackerMessages","summary":"Send a message template to trackers","description":"Creates one message per tracker from a message template and queues it for delivery. A group\ntemplate creates one message per sub-template whose tracker types include the tracker's type.\nA single template whose tracker types do not include the tracker's type creates no message\nand no error for that tracker.\n\n- The caller MUST be allowed to read the template.\n- For each tracker, the caller MUST hold a role the template allows (owner, editor or\n  borrower). Admins may send to any tracker.\n- A message whose reply carries no response id is sent once: `maxNumOfAttempts` becomes `1`.\n- Sending a message activates a tracker that is not paid yet for a billing cycle.\n\nTrackers are processed in order. An unknown tracker id or a missing role aborts the request\nwith `404` or `401`, but messages created for earlier trackers are kept. A failure while\nsaving one message is reported in `errors` instead.\n\nThe same operation is also served at `/api/trackers/messages`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrackerMessagesRequest"}}}},"responses":{"200":{"description":"Messages created. `success` is `false` when at least one message could not be saved; see\n`errors`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrackerMessagesResponse"}}}},"400":{"description":"Invalid request: `templateId` is not a valid ObjectId, the body fails validation, or the\n`Authorization` header is not of type `Bearer`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StatusError"}},"text/plain":{"schema":{"type":"string"}}}},"401":{"description":"No valid token, or the caller holds no role the template allows for one of the trackers.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StatusError"}},"text/plain":{"schema":{"type":"string"}}}},"403":{"description":"The caller is not allowed to read the template.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StatusError"}}}},"404":{"description":"The template or one of the trackers does not exist.","content":{"text/plain":{"schema":{"type":"string"}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StatusError"}}}}}}}}}
```

{% content-ref url="/pages/GZlSTdBBq82OSB9ep68p" %}
[Message templates](https://docs.racemap.com/tracker-management/trackersapi.md)
{% endcontent-ref %}

### Basics

* Identify and select the GPS trackers to which you want to send commands. The tracker management targets the commands to all devices in the above list.
* Ensure that the devices are switched on and currently connected with Racemap to receive commands.

<figure><img src="https://1672210197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSRNxaH2Ju9Flr7JhJD%2Fuploads%2Fgit-blob-9273d4bab9814a268915f9b27d3571fd8e0f5b31%2Fscreenshot-racemap.com-2024.01.08-13_37_55%20(1).png?alt=media" alt=""><figcaption><p>Selected devices in above table, 11 GPS trackers are connected with Racemap</p></figcaption></figure>

* Monitor the acknowledgment from each device to confirm the successful receipt of the command.
* Check the messages timeline for each device to track the progress of sending commands. Inspect the message details to gather additional information on each device's response.

<figure><img src="https://1672210197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSRNxaH2Ju9Flr7JhJD%2Fuploads%2Fgit-blob-276c211eebfee0046a855c330853f3b33318b19f%2Fscreenshot-racemap.com-2024.01.08-13_49_48.png?alt=media" alt=""><figcaption><p>Messages timeline of specific device.</p></figcaption></figure>

<figure><img src="https://1672210197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSRNxaH2Ju9Flr7JhJD%2Fuploads%2Fgit-blob-117e72b9762316229079cef9a4c0eef7b423b810%2Fscreenshot-racemap.com-2024.01.08-14_04_56.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Options sending commands:

* **Time:** Send the message right away ("Now") or schedule the time frame ("Not before" and "Not after") in which Racemap attemps to send the command to the device.
* **Command:** Select the command.\
  ![](https://1672210197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSRNxaH2Ju9Flr7JhJD%2Fuploads%2Fgit-blob-84053bdf52016903b1cb0818e1ad345156c73f4d%2Fscreenshot-racemap.com-2024.01.08-14_13_57.png?alt=media)
* **Transport:** By default, messaging with GPS trackers works via TCP connection. However, if you're running the devices with our M2M SIM cards, you can choose to send messages as SMS instead.\
  To receive an SMS, the device must not have an open socket connection with RACEMAP server. This provides the alternative to sending SMSs to devices that are not connected, making it useful for tasks like rebooting the device or requesting the last known location.\
  ![](https://1672210197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSRNxaH2Ju9Flr7JhJD%2Fuploads%2Fgit-blob-7330ae09d45d1e811750c96c03beb77afc68f084%2Fscreenshot-racemap_com-2024_09_26-14_46_03.png?alt=media)

{% content-ref url="/pages/PeqJ8IeSuTZT3q7B6xST" %}
[Manage SIM cards](https://docs.racemap.com/tracker-management/sim-cards.md)
{% endcontent-ref %}

### Critical commands

Two commands cannot be taken back once a device has received them:

* **Shut down** switches the device off. It has to be collected and switched on by hand — there is no way to turn a device on remotely.
* **Change the backend server** points the device at another host. It stops reporting to Racemap and can no longer be reached from the tracker management.

Sending either one opens a confirmation dialog. The dialog names the command and the number of devices it targets, and sends nothing until you type `confirm`. Every other command is still sent with a single click.

{% hint style="warning" %}
The dialog counts the devices the command actually reaches, which can be fewer than the devices you selected. Archived devices, and devices of a type the command does not cover, are left out.
{% endhint %}

You can schedule commands for a group of GPS trackers to automatically adjust the devices' settings according to the time.

A couple of days before the race:

* Switch on all devices manually.
* Place devices for a good connection.
* Select all devices in tracker management.
* Check connection and location in tracker management.
* Clear undelivered commands from messages timeline before scheduling new commands with the "Revoke all messages" function.

<figure><img src="https://1672210197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSRNxaH2Ju9Flr7JhJD%2Fuploads%2Fgit-blob-fbac5a41e470ba29ffb7df40eea14a34d22797c2%2Fscreenshot-racemap.com-2024.01.08-15_25_06%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

* Schedule commands according to SLEEP, AWAKE and RACE profile.
* Don't switch devices off after you have scheduled commands.

**SLEEP profile:** "heartbeat", every 10 to 20 min refreshes the connection to Racemap, if there is reception

<table data-full-width="false"><thead><tr><th width="81">#</th><th width="269">Command</th><th width="257">Parameter</th><th>Time</th></tr></thead><tbody><tr><td>S1</td><td>GPS Module</td><td>mode: 1</td><td>Now</td></tr><tr><td>S2</td><td>GPS Report Interval</td><td>3600; 3600</td><td>Now</td></tr><tr><td>S3</td><td>Non-Movement Detection</td><td>10; 3600; 3600</td><td>Now</td></tr></tbody></table>

{% hint style="info" %}

* Participants must not use the power button! When deploying the devices to participants the devices are turned on already.
* Devices lose about 5 to 7 % battery level in 24 hrs.
  {% endhint %}

**AWAKE profile:** It takes up to 60 min until all devices receive the new configuration. Check the tracker management if there is a device that does not establish a connection. The participant might have turned the device off. You still have time to change the device before the race starts.

<table><thead><tr><th width="77">#</th><th width="260">Command</th><th>Parameter</th><th>Not before</th><th>Not after</th></tr></thead><tbody><tr><td>A1</td><td>GPS Report Interval</td><td>180; 180</td><td>4 hrs before race starts</td><td>3 hrs before race starts</td></tr><tr><td>A2</td><td>Non-Movement Detection</td><td>10; 180; 180</td><td>4 hrs before race starts</td><td>3 hrs before race starts</td></tr></tbody></table>

**RACE profile:** It takes up to 10 min until all devices receive the new configuration.

<table><thead><tr><th width="84">#</th><th width="258">Command</th><th width="134">Parameter</th><th>Not before</th><th>Not after</th></tr></thead><tbody><tr><td>R1</td><td>GPS Module</td><td>mode: 0</td><td>1 hr before race starts</td><td>no entry</td></tr><tr><td>R2</td><td>GPS Report Interval</td><td>10; 10</td><td>1 hr before race starts</td><td>no entry</td></tr></tbody></table>

{% hint style="info" %}

* Devices lose about 5 % battery level every 1 hr.
* With 60; 60 parameter setting, devices lose about 2 % battery level every 1 hr.
  {% endhint %}

For stage events you can schedule subsequent SLEEP and RACE profiles for each stage.

After the race: Use the "Shut down" command to remotely switch devices off. When the device has received the shutdown it must be switched on manually. There is no possibility to remotely turn on a device. Because of that, "Shut down" asks you to type `confirm` before it is sent.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.racemap.com/tracker-management/messages.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
