Skip to content

AttachmentControllerAPI

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

Method HTTP request Description
deleteAllAttachments DELETE /attachments Delete all attachments
deleteAttachment DELETE /attachments/{attachmentId} Delete an attachment
downloadAttachmentAsBase64Encoded GET /attachments/{attachmentId}/base64 Get email attachment as base64 encoded string as alternative to binary responses. To read the content decode the Base64 encoded contents.
downloadAttachmentAsBytes GET /attachments/{attachmentId}/bytes Download attachments. Get email attachment bytes. If you have trouble with byte responses try the downloadAttachmentBase64 response endpoints.
getAttachment GET /attachments/{attachmentId} Get an attachment entity
getAttachmentInfo GET /attachments/{attachmentId}/metadata Get email attachment metadata information
getAttachments GET /attachments Get email attachments
uploadAttachment POST /attachments Upload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment.
uploadAttachmentBytes POST /attachments/bytes 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.
uploadMultipartForm POST /attachments/multipart Upload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment.
    open class func deleteAllAttachments() -> Promise<Void>

Delete all attachments

Example

// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new
import mailslurp


// Delete all attachments
AttachmentControllerAPI.deleteAllAttachments().then {
         // when the promise is fulfilled
     }.always {
         // regardless of whether the promise is fulfilled, or rejected
     }.catch { errorType in
         // when the promise is rejected
}

Parameters

This endpoint does not need any parameter.

Return type

Void (empty response body)

Authorization

API_KEY

HTTP request headers

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

[Back to top] [Back to API list] [Back to Model list] [Back to ]

    open class func deleteAttachment( attachmentId: String) -> Promise<Void>

Delete an attachment

Example

// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new
import mailslurp

let attachmentId = "attachmentId_example" // String | ID of attachment

// Delete an attachment
AttachmentControllerAPI.deleteAttachment(attachmentId: attachmentId).then {
         // when the promise is fulfilled
     }.always {
         // regardless of whether the promise is fulfilled, or rejected
     }.catch { errorType in
         // when the promise is rejected
}

Parameters

Name Type Description Notes
attachmentId String ID of attachment

Return type

Void (empty response body)

Authorization

API_KEY

HTTP request headers

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

[Back to top] [Back to API list] [Back to Model list] [Back to ]

    open class func downloadAttachmentAsBase64Encoded( attachmentId: String) -> Promise<DownloadAttachmentDto>

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

// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new
import mailslurp

let attachmentId = "attachmentId_example" // String | ID of attachment

// Get email attachment as base64 encoded string as alternative to binary responses. To read the content decode the Base64 encoded contents.
AttachmentControllerAPI.downloadAttachmentAsBase64Encoded(attachmentId: attachmentId).then {
         // when the promise is fulfilled
     }.always {
         // regardless of whether the promise is fulfilled, or rejected
     }.catch { errorType in
         // when the promise is rejected
}

Parameters

Name Type Description Notes
attachmentId String ID of attachment

Return type

DownloadAttachmentDto

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: /

[Back to top] [Back to API list] [Back to Model list] [Back to ]

    open class func downloadAttachmentAsBytes( attachmentId: String) -> Promise<Data>

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

// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new
import mailslurp

let attachmentId = "attachmentId_example" // String | ID of attachment

// Download attachments. Get email attachment bytes. If you have trouble with byte responses try the `downloadAttachmentBase64` response endpoints.
AttachmentControllerAPI.downloadAttachmentAsBytes(attachmentId: attachmentId).then {
         // when the promise is fulfilled
     }.always {
         // regardless of whether the promise is fulfilled, or rejected
     }.catch { errorType in
         // when the promise is rejected
}

Parameters

Name Type Description Notes
attachmentId String ID of attachment

Return type

Data

Authorization

API_KEY

HTTP request headers

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

[Back to top] [Back to API list] [Back to Model list] [Back to ]

    open class func getAttachment( attachmentId: String) -> Promise<AttachmentEntity>

Get an attachment entity

Example

// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new
import mailslurp

let attachmentId = "attachmentId_example" // String | ID of attachment

// Get an attachment entity
AttachmentControllerAPI.getAttachment(attachmentId: attachmentId).then {
         // when the promise is fulfilled
     }.always {
         // regardless of whether the promise is fulfilled, or rejected
     }.catch { errorType in
         // when the promise is rejected
}

Parameters

Name Type Description Notes
attachmentId String ID of attachment

Return type

AttachmentEntity

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: /

[Back to top] [Back to API list] [Back to Model list] [Back to ]

    open class func getAttachmentInfo( attachmentId: String) -> Promise<AttachmentMetaData>

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

// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new
import mailslurp

let attachmentId = "attachmentId_example" // String | ID of attachment

// Get email attachment metadata information
AttachmentControllerAPI.getAttachmentInfo(attachmentId: attachmentId).then {
         // when the promise is fulfilled
     }.always {
         // regardless of whether the promise is fulfilled, or rejected
     }.catch { errorType in
         // when the promise is rejected
}

Parameters

Name Type Description Notes
attachmentId String ID of attachment

Return type

AttachmentMetaData

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: /

[Back to top] [Back to API list] [Back to Model list] [Back to ]

    open class func getAttachments( page: Int? = nil,  size: Int? = nil,  sort: Sort_getAttachments? = nil,  fileNameFilter: String? = nil,  since: Date? = nil,  before: Date? = nil) -> Promise<PageAttachmentEntity>

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

// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new
import mailslurp

let page = 987 // Int | Optional page  event list pagination (optional) (default to 0)
let size = 987 // Int | Optional page size event list pagination (optional) (default to 20)
let sort = "sort_example" // String | Optional createdAt sort direction ASC or DESC (optional) (default to .asc)
let fileNameFilter = "fileNameFilter_example" // String | Optional file name and content type search filter (optional)
let since = Date() // Date | Filter by created at after the given timestamp (optional)
let before = Date() // Date | Filter by created at before the given timestamp (optional)

// Get email attachments
AttachmentControllerAPI.getAttachments(page: page, size: size, sort: sort, fileNameFilter: fileNameFilter, since: since, before: before).then {
         // when the promise is fulfilled
     }.always {
         // regardless of whether the promise is fulfilled, or rejected
     }.catch { errorType in
         // when the promise is rejected
}

Parameters

Name Type Description Notes
page Int Optional page event list pagination [optional] [default to 0]
size Int Optional page size event list pagination [optional] [default to 20]
sort String Optional createdAt sort direction ASC or DESC [optional] [default to .asc]
fileNameFilter String Optional file name and content type search filter [optional]
since Date Filter by created at after the given timestamp [optional]
before Date Filter by created at before the given timestamp [optional]

Return type

PageAttachmentEntity

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: /

[Back to top] [Back to API list] [Back to Model list] [Back to ]

    open class func uploadAttachment( uploadAttachmentOptions: UploadAttachmentOptions) -> Promise<[String]>

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

Example

// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new
import mailslurp

let uploadAttachmentOptions = UploadAttachmentOptions(contentType: "contentType_example", filename: "filename_example", base64Contents: "base64Contents_example") // UploadAttachmentOptions | 

// Upload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment.
AttachmentControllerAPI.uploadAttachment(uploadAttachmentOptions: uploadAttachmentOptions).then {
         // when the promise is fulfilled
     }.always {
         // regardless of whether the promise is fulfilled, or rejected
     }.catch { errorType in
         // when the promise is rejected
}

Parameters

Name Type Description Notes
uploadAttachmentOptions UploadAttachmentOptions

Return type

[String]

Authorization

API_KEY

HTTP request headers

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

[Back to top] [Back to API list] [Back to Model list] [Back to ]

    open class func uploadAttachmentBytes( inlineObject1: InlineObject1,  contentType: String? = nil,  filename: String? = nil) -> Promise<[String]>

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.

Example

// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new
import mailslurp

let inlineObject1 = inline_object_1(short: 123, char: "char_example", int: 123, long: 123, float: 123, double: 123, direct: false, readOnly: false) // InlineObject1 | 
let contentType = "contentType_example" // String | Optional contentType for file. For instance `application/pdf` (optional)
let filename = "filename_example" // String | Optional filename to save upload with (optional)

// 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.
AttachmentControllerAPI.uploadAttachmentBytes(inlineObject1: inlineObject1, contentType: contentType, filename: filename).then {
         // when the promise is fulfilled
     }.always {
         // regardless of whether the promise is fulfilled, or rejected
     }.catch { errorType in
         // when the promise is rejected
}

Parameters

Name Type Description Notes
inlineObject1 InlineObject1
contentType String Optional contentType for file. For instance application/pdf [optional]
filename String Optional filename to save upload with [optional]

Return type

[String]

Authorization

API_KEY

HTTP request headers

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

[Back to top] [Back to API list] [Back to Model list] [Back to ]

    open class func uploadMultipartForm( contentType: String? = nil,  filename: String? = nil,  xFilename: String? = nil,  inlineObject: InlineObject? = nil) -> Promise<[String]>

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

Example

// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new
import mailslurp

let contentType = "contentType_example" // String | Optional content type of attachment (optional)
let filename = "filename_example" // String | Optional name of file (optional)
let xFilename = "xFilename_example" // String | Optional content type header of attachment (optional)
let inlineObject = inline_object(contentTypeHeader: "contentTypeHeader_example", file: URL(string: "https://example.com")!) // InlineObject |  (optional)

// Upload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment.
AttachmentControllerAPI.uploadMultipartForm(contentType: contentType, filename: filename, xFilename: xFilename, inlineObject: inlineObject).then {
         // when the promise is fulfilled
     }.always {
         // regardless of whether the promise is fulfilled, or rejected
     }.catch { errorType in
         // when the promise is rejected
}

Parameters

Name Type Description Notes
contentType String Optional content type of attachment [optional]
filename String Optional name of file [optional]
xFilename String Optional content type header of attachment [optional]
inlineObject InlineObject [optional]

Return type

[String]

Authorization

API_KEY

HTTP request headers

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

[Back to top] [Back to API list] [Back to Model list] [Back to ]