---
title: "Upload an attachment via a signed URL"
method: POST
path: "/rmm/pre-sign-attachment"
tags: ["Attachments"]
---

# Upload an attachment via a signed URL

`POST /rmm/pre-sign-attachment`

## Request

- Base URL: `https://api.bulksms.com/v1`
- URL: `https://api.bulksms.com/v1/rmm/pre-sign-attachment`
- Auth: HTTP basic
- TypeScript: <https://skmtc.dev/bulksms/apis/bulksms-json-rest-api/docs/rmm/pre-sign-attachment/post.ts> (a function with typed inputs; its response is checked against the schema)

When composing an SMS, you can add SMS attachments by adding a URL to your text. When the recipient clicks on the URL, the attached file will be downloaded and opened on their mobile device.  

The best way to do this is to store the file on a web server you own and use that URL in the SMS text. This URL will be easily recognisable to your message recipient and ties your message back to your brand or company. 

If that’s not possible, you can use BulkSMS storage to keep the files that you want to attach to your SMS. These files will be deleted after 30 days as per our fair use policy.  

We recommend you keep this file size below 20 MB, as larger files may be deleted without warning. 

To use the BulkSMS storage, follow these three steps:

**Step 1**: Use your BulkSMS credentials (or your API Token) to request a pre-signed URL.  This is what this `pre-sign-attachment` method is for.  It returns a PreSignInfo object that you will use in the other two steps.

**Step 2**: Upload the file using a standard HTTP `PUT` request. For your `PUT` request, use the value of `putURL` from the PreSignInfo object as the request address.  You also have to add the entries from the `fields` property (of the PreSignInfo object) to the headers of your 'PUT' request. You send the file content as the body of the `PUT` request.

**Step 3**: Now you can use the value of `fetchURL` from the PreSignInfo object in the body of your SMS messages and send those using the usual messaging API (described elsewhere in this document).  If you send the same file to many recipients, it is safe to use the same URL for all of them.

If you need to, take a closer look at the example program (on the right-hand side) to get a better idea of how to implement this process.

## Request body

- PreSignRequest
  - `fileExtension` string: The extension of the file. Usually related to the media type.
  - `mediaType` string: The media type of the file you would like to upload. If you are not sure what value to use here, check out the standard [list of media types](https://www.iana.org/assignments/media-types/media-types.xhtml).

## Response `200`

A PreSignInfo object

- PreSignInfo
  - `putUrl` string: The address of the PUT request to upload the file.
  - `fetchUrl` string: The URL you use in your SMS text. It is the file location.
  - `fields` object[]: Name value objects to add to the headers of the PUT request.
    - `name` string: The header name
    - `value` string: The header value

---

[API](https://skmtc.dev/bulksms/apis/bulksms-json-rest-api.md) - [All operations](https://skmtc.dev/bulksms/apis/bulksms-json-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/bulksms/apis/bulksms-json-rest-api/revisions/f923d2ecca43?raw)
