Gmail API
  1. users
Gmail API
  • users
    • /gmail/v1/users/{userId}/drafts
      GET
    • /gmail/v1/users/{userId}/drafts
      POST
    • /gmail/v1/users/{userId}/drafts/send
      POST
    • /gmail/v1/users/{userId}/drafts/{id}
      DELETE
    • /gmail/v1/users/{userId}/drafts/{id}
      GET
    • /gmail/v1/users/{userId}/drafts/{id}
      PUT
    • /gmail/v1/users/{userId}/history
      GET
    • /gmail/v1/users/{userId}/labels
      GET
    • /gmail/v1/users/{userId}/labels
      POST
    • /gmail/v1/users/{userId}/labels/{id}
      DELETE
    • /gmail/v1/users/{userId}/labels/{id}
      GET
    • /gmail/v1/users/{userId}/labels/{id}
      PATCH
    • /gmail/v1/users/{userId}/labels/{id}
      PUT
    • /gmail/v1/users/{userId}/messages
      GET
    • /gmail/v1/users/{userId}/messages
      POST
    • /gmail/v1/users/{userId}/messages/batchDelete
      POST
    • /gmail/v1/users/{userId}/messages/batchModify
      POST
    • /gmail/v1/users/{userId}/messages/import
      POST
    • /gmail/v1/users/{userId}/messages/send
      POST
    • /gmail/v1/users/{userId}/messages/{id}
      DELETE
    • /gmail/v1/users/{userId}/messages/{id}
      GET
    • /gmail/v1/users/{userId}/messages/{id}/modify
      POST
    • /gmail/v1/users/{userId}/messages/{id}/trash
      POST
    • /gmail/v1/users/{userId}/messages/{id}/untrash
      POST
    • /gmail/v1/users/{userId}/messages/{messageId}/attachments/{id}
      GET
    • /gmail/v1/users/{userId}/profile
      GET
    • /gmail/v1/users/{userId}/settings/autoForwarding
      GET
    • /gmail/v1/users/{userId}/settings/autoForwarding
      PUT
    • /gmail/v1/users/{userId}/settings/cse/identities
      GET
    • /gmail/v1/users/{userId}/settings/cse/identities
      POST
    • /gmail/v1/users/{userId}/settings/cse/identities/{cseEmailAddress}
      DELETE
    • /gmail/v1/users/{userId}/settings/cse/identities/{cseEmailAddress}
      GET
    • /gmail/v1/users/{userId}/settings/cse/identities/{emailAddress}
      PATCH
    • /gmail/v1/users/{userId}/settings/cse/keypairs
      GET
    • /gmail/v1/users/{userId}/settings/cse/keypairs
      POST
    • /gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}
      GET
    • /gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}:disable
      POST
    • /gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}:enable
      POST
    • /gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}:obliterate
      POST
    • /gmail/v1/users/{userId}/settings/delegates
      GET
    • /gmail/v1/users/{userId}/settings/delegates
      POST
    • /gmail/v1/users/{userId}/settings/delegates/{delegateEmail}
      DELETE
    • /gmail/v1/users/{userId}/settings/delegates/{delegateEmail}
      GET
    • /gmail/v1/users/{userId}/settings/filters
      GET
    • /gmail/v1/users/{userId}/settings/filters
      POST
    • /gmail/v1/users/{userId}/settings/filters/{id}
      DELETE
    • /gmail/v1/users/{userId}/settings/filters/{id}
      GET
    • /gmail/v1/users/{userId}/settings/forwardingAddresses
      GET
    • /gmail/v1/users/{userId}/settings/forwardingAddresses
      POST
    • /gmail/v1/users/{userId}/settings/forwardingAddresses/{forwardingEmail}
      DELETE
    • /gmail/v1/users/{userId}/settings/forwardingAddresses/{forwardingEmail}
      GET
    • /gmail/v1/users/{userId}/settings/imap
      GET
    • /gmail/v1/users/{userId}/settings/imap
      PUT
    • /gmail/v1/users/{userId}/settings/language
      GET
    • /gmail/v1/users/{userId}/settings/language
      PUT
    • /gmail/v1/users/{userId}/settings/pop
      GET
    • /gmail/v1/users/{userId}/settings/pop
      PUT
    • /gmail/v1/users/{userId}/settings/sendAs
      GET
    • /gmail/v1/users/{userId}/settings/sendAs
      POST
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}
      DELETE
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}
      GET
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}
      PATCH
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}
      PUT
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo
      GET
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo
      POST
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}
      DELETE
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}
      GET
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}/setDefault
      POST
    • /gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/verify
      POST
    • /gmail/v1/users/{userId}/settings/vacation
      GET
    • /gmail/v1/users/{userId}/settings/vacation
      PUT
    • /gmail/v1/users/{userId}/stop
      POST
    • /gmail/v1/users/{userId}/threads
      GET
    • /gmail/v1/users/{userId}/threads/{id}
      DELETE
    • /gmail/v1/users/{userId}/threads/{id}
      GET
    • /gmail/v1/users/{userId}/threads/{id}/modify
      POST
    • /gmail/v1/users/{userId}/threads/{id}/trash
      POST
    • /gmail/v1/users/{userId}/threads/{id}/untrash
      POST
    • /gmail/v1/users/{userId}/watch
      POST
  1. users

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

POST
/gmail/v1/users/{userId}/messages/import
users
Imports a message into only this user's mailbox, with standard email delivery scanning and classification similar to receiving via SMTP. This method doesn't perform SPF checks, so it might not work for some spam messages, such as those attempting to perform domain spoofing. This method does not send a message. Note: This function doesn't trigger forwarding rules or filters set up by the user.
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://gmail.googleapis.com//gmail/v1/users//messages/import' \
--header 'Content-Type: text/plain' \
--data-raw ''
Response Response Example
{
  "historyId": "string",
  "id": "string",
  "internalDate": "string",
  "labelIds": [
    "string"
  ],
  "payload": {
    "body": {
      "attachmentId": "string",
      "data": "string",
      "size": 0
    },
    "filename": "string",
    "headers": [
      {
        "name": "string",
        "value": "string"
      }
    ],
    "mimeType": "string",
    "partId": "string",
    "parts": [
      {}
    ]
  },
  "raw": "string",
  "sizeEstimate": 0,
  "snippet": "string",
  "threadId": "string"
}

Request

Path Params
userId
string 
required
The user's email address. The special value me can be used to indicate the authenticated user.
Query Params
deleted
string 
optional
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
string 
optional
Source for Gmail's internal date of the message.
neverMarkSpam
string 
optional
Ignore the Gmail spam classifier decision and never mark this email as SPAM in the mailbox.
processForCalendar
string 
optional
Process calendar invites in the email and add any extracted meetings to the Google Calendar for this user.

Responses

🟢200Successful response
application/json
Body
An email message.
historyId
string <uint64>
optional
The ID of the last history record that modified this message.
id
string 
optional
The immutable ID of the message.
internalDate
string <int64>
optional
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
array[string]
optional
List of IDs of labels applied to this message.
payload
object (MessagePart) 
optional
The parsed email structure in the message parts.
body
object (MessagePartBody) 
optional
The message part body for this part, which may be empty for container MIME message parts.
filename
string 
optional
The filename of the attachment. Only present if this message part represents an attachment.
headers
array[object (MessagePartHeader) {2}] 
optional
List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as To, From, and Subject.
mimeType
string 
optional
The MIME type of the message part.
partId
string 
optional
The immutable ID of the message part.
parts
array[object (MessagePart) {6}] 
optional
The child MIME message parts of this part. This only applies to container MIME message parts, for example multipart/*. For non- container MIME message part types, such as text/plain, this field is empty. For more information, see RFC 1521.
raw
string <byte>
optional
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.
sizeEstimate
integer <int32>
optional
Estimated size in bytes of the message.
snippet
string 
optional
A short part of the message text.
threadId
string 
optional
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.
Modified at 2023-08-15 05:40:23
Previous
/gmail/v1/users/{userId}/messages/batchModify
Next
/gmail/v1/users/{userId}/messages/send
Built with