---
agentTools:
  projectIndex: https://developer-docs.gomotive.com/llms.txt
---

# Send a message to a user

**Purpose**: Use the following API to send a message to a user or a driver. You must specify the recipient ID of the\
user or the driver to send the message. Also, specify the message or an attachment that you would like\
to send to the user.

```ruby Ruby (OAuth 2.0)
require 'uri'
require 'net/http'
require 'json'

url = URI('https://api.gomotive.com/v1/messages')

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request['Authorization'] = "Bearer <OAUTH_TOKEN>"
request['X-User-Id']     = <api user id>
request['Content-Type']  = 'application/json'
params = {
  :recipient_id => <user id>,
  :status       => 'read',
  :body         => 'hello',
}
request.body = params.to_json

response = http.request(request)
puts response.read_body
```

## Response Parameters

### success

* **Type**: Boolean
* **Description**: Dentes if the message was sent. In most cases, the bool value for the parameter 'success" will be "true". It wil not be false. In case the sending of the message has failed. you will the corresponding error message.

***

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Motive",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.gomotive.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/v1/messages": {
      "post": {
        "summary": "Send a message to a user",
        "description": "",
        "operationId": "send-a-message-to-a-user",
        "parameters": [
          {
            "name": "recipient_id",
            "in": "query",
            "description": "Specify the Id of the user to whom you are sending this message.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "body",
            "in": "query",
            "description": "Enter the body of the message that you are sending to your user.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Time-Zone",
            "in": "header",
            "description": "Specify the timezone for formatting the timestamps.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Metric-Units",
            "in": "header",
            "description": "Specify if you want to use the Metric units or the Imperial units. TRUE: Metric units. FALSE: Imperial Units",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "description": "Specify the ID of the user who is accessing this endpoint.",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Send a message to a user": {
                    "value": "{\n  \"success\": true\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true,
                      "default": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Could not send the message": {
                    "value": "{\n  \"error_message\": \"message could not be delivered\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "error_message": {
                      "type": "string",
                      "example": "message could not be delivered"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "404",
            "content": {
              "application/json": {
                "examples": {
                  "User not found": {
                    "value": "{\n  \"error_message\": \"user not found\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "error_message": {
                      "type": "string",
                      "example": "user not found"
                    }
                  }
                }
              }
            }
          }
        },
        "deprecated": false
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true,
  "_id": "66acf64a829e88001980fbf2:66bcf12fe259f40031452c6f"
}
```