users

POST /gmail/v1/users/{userId}/messages

Changed on

Directly inserts a message into only this user's mailbox similar to IMAP APPEND, bypassing most scanning and classification. Does not send a message. For more information, see Create and send email messages.

Request

  • Base URL
    https://gmail.googleapis.com
  • Auth
    • OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://mail.google.com/
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://mail.google.com/
    • or OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/gmail.insert
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/gmail.insert
    • or OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/gmail.modify
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/gmail.modify

Path parameters

userId, string required

The user's email address. The special value me can be used to indicate the authenticated user.

Query parameters

$.xgafv, '1' | '2'

V1 error format.

access_token, string

OAuth access token.

alt, 'json' | 'media' | 'proto'

Data format for response.

callback, string

JSONP

fields, string

Selector specifying which fields to include in a partial response.

key, string

API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.

oauth_token, string

OAuth 2.0 token for the current user.

prettyPrint, boolean

Returns response with indentations and line breaks.

quotaUser, string

Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

uploadType, string

Legacy upload protocol for media (e.g. "media", "multipart").

upload_protocol, string

Upload protocol for media (e.g. "raw", "multipart").

deleted, boolean

Mark the email as permanently deleted (not TRASH) and only visible in Google Vault to a Vault administrator. Only used for Google Workspace accounts.

internalDateSource, 'receivedTime' | 'dateHeader'

Source for Gmail's internal date of the message.

Request body

Message required

An email message.

classificationLabelValues, ClassificationLabelValue[]

Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts. There's a limit of 20 Classification Label values per request. If the Classification Label values exceeds the maximum allowed number, the request fails.

historyId, string uint64

The ID of the last history record that modified this message.

id, string

The immutable ID of the message.

internalDate, string int64

The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the Date header. However, for API-migrated mail, it can be configured by client to be based on the Date header.

labelIds, string[]

List of IDs of labels applied to this message.

payload, MessagePart

A single MIME message part.

raw, string byte

The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in messages.get and drafts.get responses when the format=RAW parameter is supplied. @required gmail.users.drafts.create gmail.users.drafts.update

sizeEstimate, integer

Estimated size in bytes of the message.

snippet, string

A short part of the message text.

threadId, string

The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested threadId must be specified on the Message or Draft.Message you supply with your request. 2. The References and In-Reply-To headers must be set in compliance with the RFC 2822 standard. 3. The Subject headers must match.

Response

Successful response

Message required

An email message.

classificationLabelValues, ClassificationLabelValue[]

Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts. There's a limit of 20 Classification Label values per request. If the Classification Label values exceeds the maximum allowed number, the request fails.

historyId, string uint64

The ID of the last history record that modified this message.

id, string

The immutable ID of the message.

internalDate, string int64

The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the Date header. However, for API-migrated mail, it can be configured by client to be based on the Date header.

labelIds, string[]

List of IDs of labels applied to this message.

payload, MessagePart

A single MIME message part.

raw, string byte

The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in messages.get and drafts.get responses when the format=RAW parameter is supplied. @required gmail.users.drafts.create gmail.users.drafts.update

sizeEstimate, integer

Estimated size in bytes of the message.

snippet, string

A short part of the message text.

threadId, string

The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested threadId must be specified on the Message or Draft.Message you supply with your request. 2. The References and In-Reply-To headers must be set in compliance with the RFC 2822 standard. 3. The Subject headers must match.

Changes

    • info

      the security scope https://mail.google.com/ was added to the endpoint's security scheme Oauth2

    • info

      the security scope https://mail.google.com/ was added to the endpoint's security scheme Oauth2c

    • info

      the security scope https://www.googleapis.com/auth/gmail.modify was removed from the endpoint's security scheme Oauth2

    1 more change in this revision