MailSlurpClient::AttachmentControllerApi

All URIs are relative to https://api.mailslurp.com

MethodHTTP requestDescription
delete_all_attachmentsDELETE /attachmentsDelete all attachments
delete_attachmentDELETE /attachments/{attachmentId}Delete an attachment
download_attachment_as_base64_encodedGET /attachments/{attachmentId}/base64Get email attachment as base64 encoded string as alternative to binary responses. To read the content decode the Base64 encoded contents.
download_attachment_as_bytesGET /attachments/{attachmentId}/bytesDownload attachments. Get email attachment bytes. If you have trouble with byte responses try the downloadAttachmentBase64 response endpoints.
get_attachmentGET /attachments/{attachmentId}Get an attachment entity
get_attachment_infoGET /attachments/{attachmentId}/metadataGet email attachment metadata information
get_attachmentsGET /attachmentsGet email attachments
upload_attachmentPOST /attachmentsUpload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment.
upload_attachment_bytesPOST /attachments/bytesUpload an attachment for sending using file byte stream input octet stream. Returns an array whose first element is the ID of the uploaded attachment.
upload_multipart_formPOST /attachments/multipartUpload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment.

delete_all_attachments

delete_all_attachments

Delete all attachments

Example

# load the gem
require 'mailslurp_client'
# setup authorization
MailSlurpClient.configure do |config|
  # Configure API key authorization: API_KEY
  config.api_key['x-api-key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['x-api-key'] = 'Bearer'
end

api_instance = MailSlurpClient::AttachmentControllerApi.new

begin
  #Delete all attachments
  api_instance.delete_all_attachments
rescue MailSlurpClient::ApiError => e
  puts "Exception when calling AttachmentControllerApi->delete_all_attachments: #{e}"
end

Parameters

This endpoint does not need any parameter.

Return type

nil (empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

delete_attachment

delete_attachment(attachment_id)

Delete an attachment

Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with SendEmailOptions when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused.

Example

# load the gem
require 'mailslurp_client'
# setup authorization
MailSlurpClient.configure do |config|
  # Configure API key authorization: API_KEY
  config.api_key['x-api-key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['x-api-key'] = 'Bearer'
end

api_instance = MailSlurpClient::AttachmentControllerApi.new
attachment_id = 'attachment_id_example' # String | ID of attachment

begin
  #Delete an attachment
  api_instance.delete_attachment(attachment_id)
rescue MailSlurpClient::ApiError => e
  puts "Exception when calling AttachmentControllerApi->delete_attachment: #{e}"
end

Parameters

NameTypeDescriptionNotes
attachment_idStringID of attachment

Return type

nil (empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

download_attachment_as_base64_encoded

DownloadAttachmentDto download_attachment_as_base64_encoded(attachment_id)

Get email attachment as base64 encoded string as alternative to binary responses. To read the content decode the Base64 encoded contents.

Returns the specified attachment for a given email as a base 64 encoded string. The response type is application/json. This method is similar to the downloadAttachment method but allows some clients to get around issues with binary responses.

Example

# load the gem
require 'mailslurp_client'
# setup authorization
MailSlurpClient.configure do |config|
  # Configure API key authorization: API_KEY
  config.api_key['x-api-key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['x-api-key'] = 'Bearer'
end

api_instance = MailSlurpClient::AttachmentControllerApi.new
attachment_id = 'attachment_id_example' # String | ID of attachment

begin
  #Get email attachment as base64 encoded string as alternative to binary responses. To read the content decode the Base64 encoded contents.
  result = api_instance.download_attachment_as_base64_encoded(attachment_id)
  p result
rescue MailSlurpClient::ApiError => e
  puts "Exception when calling AttachmentControllerApi->download_attachment_as_base64_encoded: #{e}"
end

Parameters

NameTypeDescriptionNotes
attachment_idStringID of attachment

Return type

DownloadAttachmentDto

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

download_attachment_as_bytes

String download_attachment_as_bytes(attachment_id)

Download attachments. Get email attachment bytes. If you have trouble with byte responses try the downloadAttachmentBase64 response endpoints.

Returns the specified attachment for a given email as a stream / array of bytes. You can find attachment ids in email responses endpoint responses. The response type is application/octet-stream.

Example

# load the gem
require 'mailslurp_client'
# setup authorization
MailSlurpClient.configure do |config|
  # Configure API key authorization: API_KEY
  config.api_key['x-api-key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['x-api-key'] = 'Bearer'
end

api_instance = MailSlurpClient::AttachmentControllerApi.new
attachment_id = 'attachment_id_example' # String | ID of attachment

begin
  #Download attachments. Get email attachment bytes. If you have trouble with byte responses try the `downloadAttachmentBase64` response endpoints.
  result = api_instance.download_attachment_as_bytes(attachment_id)
  p result
rescue MailSlurpClient::ApiError => e
  puts "Exception when calling AttachmentControllerApi->download_attachment_as_bytes: #{e}"
end

Parameters

NameTypeDescriptionNotes
attachment_idStringID of attachment

Return type

String

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/octet-stream

get_attachment

AttachmentEntity get_attachment(attachment_id)

Get an attachment entity

Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with SendEmailOptions when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused.

Example

# load the gem
require 'mailslurp_client'
# setup authorization
MailSlurpClient.configure do |config|
  # Configure API key authorization: API_KEY
  config.api_key['x-api-key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['x-api-key'] = 'Bearer'
end

api_instance = MailSlurpClient::AttachmentControllerApi.new
attachment_id = 'attachment_id_example' # String | ID of attachment

begin
  #Get an attachment entity
  result = api_instance.get_attachment(attachment_id)
  p result
rescue MailSlurpClient::ApiError => e
  puts "Exception when calling AttachmentControllerApi->get_attachment: #{e}"
end

Parameters

NameTypeDescriptionNotes
attachment_idStringID of attachment

Return type

AttachmentEntity

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

get_attachment_info

AttachmentMetaData get_attachment_info(attachment_id)

Get email attachment metadata information

Returns the metadata for an attachment. It is saved separately to the content of the attachment. Contains properties name and content-type and content-length in bytes for a given attachment.

Example

# load the gem
require 'mailslurp_client'
# setup authorization
MailSlurpClient.configure do |config|
  # Configure API key authorization: API_KEY
  config.api_key['x-api-key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['x-api-key'] = 'Bearer'
end

api_instance = MailSlurpClient::AttachmentControllerApi.new
attachment_id = 'attachment_id_example' # String | ID of attachment

begin
  #Get email attachment metadata information
  result = api_instance.get_attachment_info(attachment_id)
  p result
rescue MailSlurpClient::ApiError => e
  puts "Exception when calling AttachmentControllerApi->get_attachment_info: #{e}"
end

Parameters

NameTypeDescriptionNotes
attachment_idStringID of attachment

Return type

AttachmentMetaData

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

get_attachments

PageAttachmentEntity get_attachments(opts)

Get email attachments

Get all attachments in paginated response. Each entity contains meta data for the attachment such as name and content-type. Use the attachmentId and the download endpoints to get the file contents.

Example

# load the gem
require 'mailslurp_client'
# setup authorization
MailSlurpClient.configure do |config|
  # Configure API key authorization: API_KEY
  config.api_key['x-api-key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['x-api-key'] = 'Bearer'
end

api_instance = MailSlurpClient::AttachmentControllerApi.new
opts = {
  before: DateTime.parse('2013-10-20T19:20:30+01:00'), # DateTime | Filter by created at before the given timestamp
  file_name_filter: 'file_name_filter_example', # String | Optional file name and content type search filter
  page: 0, # Integer | Optional page  event list pagination
  since: DateTime.parse('2013-10-20T19:20:30+01:00'), # DateTime | Filter by created at after the given timestamp
  size: 20, # Integer | Optional page size event list pagination
  sort: 'ASC' # String | Optional createdAt sort direction ASC or DESC
}

begin
  #Get email attachments
  result = api_instance.get_attachments(opts)
  p result
rescue MailSlurpClient::ApiError => e
  puts "Exception when calling AttachmentControllerApi->get_attachments: #{e}"
end

Parameters

NameTypeDescriptionNotes
beforeDateTimeFilter by created at before the given timestamp[optional]
file_name_filterStringOptional file name and content type search filter[optional]
pageIntegerOptional page event list pagination[optional] [default to 0]
sinceDateTimeFilter by created at after the given timestamp[optional]
sizeIntegerOptional page size event list pagination[optional] [default to 20]
sortStringOptional createdAt sort direction ASC or DESC[optional] [default to ‘ASC’]

Return type

PageAttachmentEntity

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

upload_attachment

Array upload_attachment(upload_options)

Upload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment.

Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with SendEmailOptions when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused.

Example

# load the gem
require 'mailslurp_client'
# setup authorization
MailSlurpClient.configure do |config|
  # Configure API key authorization: API_KEY
  config.api_key['x-api-key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['x-api-key'] = 'Bearer'
end

api_instance = MailSlurpClient::AttachmentControllerApi.new
upload_options = MailSlurpClient::UploadAttachmentOptions.new # UploadAttachmentOptions | uploadOptions

begin
  #Upload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment.
  result = api_instance.upload_attachment(upload_options)
  p result
rescue MailSlurpClient::ApiError => e
  puts "Exception when calling AttachmentControllerApi->upload_attachment: #{e}"
end

Parameters

NameTypeDescriptionNotes
upload_optionsUploadAttachmentOptionsuploadOptions

Return type

Array

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

upload_attachment_bytes

Array upload_attachment_bytes(opts)

Upload an attachment for sending using file byte stream input octet stream. Returns an array whose first element is the ID of the uploaded attachment.

Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with SendEmailOptions when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused.

Example

# load the gem
require 'mailslurp_client'
# setup authorization
MailSlurpClient.configure do |config|
  # Configure API key authorization: API_KEY
  config.api_key['x-api-key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['x-api-key'] = 'Bearer'
end

api_instance = MailSlurpClient::AttachmentControllerApi.new
opts = {
  content_type: 'content_type_example', # String | Optional contentType for file. For instance `application/pdf`
  filename: 'filename_example', # String | Optional filename to save upload with
  byte_array: 'byte_array_example' # String | Byte array request body
}

begin
  #Upload an attachment for sending using file byte stream input octet stream. Returns an array whose first element is the ID of the uploaded attachment.
  result = api_instance.upload_attachment_bytes(opts)
  p result
rescue MailSlurpClient::ApiError => e
  puts "Exception when calling AttachmentControllerApi->upload_attachment_bytes: #{e}"
end

Parameters

NameTypeDescriptionNotes
content_typeStringOptional contentType for file. For instance application/pdf[optional]
filenameStringOptional filename to save upload with[optional]
byte_arrayStringByte array request body[optional]

Return type

Array

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/octet-stream
  • Accept: application/json

upload_multipart_form

Array upload_multipart_form(file, opts)

Upload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment.

Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with SendEmailOptions when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused.

Example

# load the gem
require 'mailslurp_client'
# setup authorization
MailSlurpClient.configure do |config|
  # Configure API key authorization: API_KEY
  config.api_key['x-api-key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['x-api-key'] = 'Bearer'
end

api_instance = MailSlurpClient::AttachmentControllerApi.new
file = File.new('/path/to/file') # File | file
opts = {
  content_type: 'content_type_example', # String | Optional content type of attachment
  filename: 'filename_example', # String | Optional name of file
  x_filename: 'x_filename_example' # String | Optional content type header of attachment
}

begin
  #Upload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment.
  result = api_instance.upload_multipart_form(file, opts)
  p result
rescue MailSlurpClient::ApiError => e
  puts "Exception when calling AttachmentControllerApi->upload_multipart_form: #{e}"
end

Parameters

NameTypeDescriptionNotes
fileFilefile
content_typeStringOptional content type of attachment[optional]
filenameStringOptional name of file[optional]
x_filenameStringOptional content type header of attachment[optional]

Return type

Array

Authorization

API_KEY

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json