# iPhone and iPad: upload with a Shortcut

How to build a Shortcut that uploads a photo or screenshot to hematite from the share sheet and copies its link: make a key, then six actions in Shortcuts.

On an iPhone or iPad, a Shortcut of your own uploads to hematite from the share sheet: share a screenshot or a photo, choose **hematite**, and the link is on your clipboard. You build it once in the Shortcuts app, with an upload key from hematite. Do it all on the phone, so the key is on its clipboard when you need it.

## Make a key

1. **Open Uploaders.** On the phone, sign in to hematite and open [Settings → Uploaders](https://hematite.gg/settings/uploaders).
2. **Get a key.** Press **Get key** beside **iPhone and iPad**, then **Make key**.
3. **Copy it.** Press **Copy**. It's shown only this once; if you lose it, remove it and make another.

## Build the Shortcut

In the Shortcuts app, press **+** for a new shortcut and name it **hematite**. Then add these actions, in this order:

1. **Receive input from the share sheet.** Open the shortcut's details (ⓘ), turn on **Show in Share Sheet**, and let it receive **Images** only.
2. **Convert Image.** Convert **Shortcut Input** to **JPEG**, with **Preserve Metadata** off. The camera's HEIC photos become something hematite takes, and the picture's location stays on the phone.
3. **Get Contents of URL.** Set the address to `https://api.hematite.gg/v1/images`, then open **Show More**:
   - **Method:** POST.
   - **Headers:** add one, `Authorization`, and paste your key as its value.
   - **Request Body:** Form. Add a **File** field named `file`, with **Converted Image** as its value, and a **Text** field named `p` with `shortcut`.
4. **Get Dictionary Value.** Get the **Value** for `data.shareUrl` in **Contents of URL**.
5. **Copy to Clipboard.** Copy the **Dictionary Value**.
6. **Show Notification.** Say `Link copied`, so you know it's done.

Now share a screenshot or a photo, from Photos or right after you take it, and choose **hematite** in the share sheet. When it's up, the link is on your clipboard.

> **Warning: The Shortcut holds your key: don't share it**
>
> Anyone with the key can upload to your account until it expires or you remove
> it. Shared, the Shortcut takes the key with it. If it gets out, remove the key
> and make a new one.

## How its uploads come out

- **They take your [upload settings](https://hematite.gg/settings/upload):** who can see them, when they delete themselves, how they're compressed. The link follows your [link settings](https://hematite.gg/docs/guides/share-links).
- **Up to 16 MB each,** as JPEG. A photo from the camera at full size is well under it.

## When the link doesn't come

If the clipboard holds nothing new, hematite refused the upload. Run the shortcut from the Shortcuts app on a photo and look at what **Get Contents of URL** returned: its `message` says why.

| It says                                    | What it means                                  | What to do                                   |
| ------------------------------------------ | ---------------------------------------------- | -------------------------------------------- |
| Authentication is required for this route. | The key is wrong, expired or removed           | Make a new key and paste it into the header  |
| Storage limit reached                      | Your plan's storage is full                    | Delete something, or see [pricing](https://hematite.gg/pricing) |
| Request validation failed.                 | The picture is over 16 MB, or wasn't converted | Check the **Convert Image** action           |

## Your key

It lasts 90 days and counts toward your ten upload tokens. It's listed as **Shortcut** on [Settings → Uploaders](https://hematite.gg/settings/uploaders) and in [Settings → Security](https://hematite.gg/settings/security). Remove it in either place and the Shortcut stops uploading. To go on, make a new key and paste it into the **Authorization** header. On Android, [HTTP Shortcuts](https://hematite.gg/docs/uploaders/android) does the same.
