# Sign an upload

Source: https://docs.musicnerd.net/api-reference/vault/sign-upload

Sign an upload

## POST /api/vault/upload/sign

Full OpenAPI specification: https://docs.musicnerd.net/spec/vault.json

## Authentication

This operation requires one of the security alternatives in the specification below. Security scheme definitions are included where present in the published specification.

[Authentication guide](https://docs.musicnerd.net/authentication)

## Operation and referenced schemas

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Music Nerd API: vault uploads",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://musicnerd-api.vercel.app",
      "description": "Production"
    },
    {
      "url": "https://musicnerd-api-staging.vercel.app",
      "description": "Staging (staging database)"
    }
  ],
  "paths": {
    "/api/vault/upload/sign": {
      "post": {
        "summary": "Sign an upload",
        "operationId": "signVaultUpload",
        "security": [
          {
            "privyBearer": []
          }
        ],
        "description": "Step one of a file upload to an artist's vault: checks the file's name, type and size, then returns a signed storage URL to `PUT` the file to and a ticket for [Complete an upload](/api-reference/vault/complete-upload) that expires after 15 minutes. Files up to 10 MB: PDF, TXT, MD, CSV, JSON, DOC, DOCX, PNG, JPEG, WebP, MP3 and WAV. A file whose `type` is empty or nonstandard is resolved from its extension, and `contentType` says which type was settled on.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "artistId",
                  "name",
                  "type",
                  "size"
                ],
                "properties": {
                  "artistId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The artist's ID."
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 255,
                    "description": "The file's name, with its extension."
                  },
                  "type": {
                    "type": "string",
                    "description": "The browser-reported MIME type. May be empty."
                  },
                  "size": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10485760,
                    "description": "The file's size in bytes, at most 10 MB (10,485,760 bytes)."
                  }
                }
              },
              "example": {
                "artistId": "aab92f80-f9e1-4299-aa33-7dd85c8de5d3",
                "name": "press-kit.pdf",
                "type": "application/pdf",
                "size": 482133
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Where to send the file, and the ticket to complete with.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "signedUrl",
                    "contentType",
                    "ticket"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "signedUrl": {
                      "type": "string",
                      "format": "uri",
                      "description": "A Supabase Storage signed upload URL. `PUT` the file to it as `multipart/form-data` with the file in an unnamed field. Valid for a short time."
                    },
                    "contentType": {
                      "type": "string",
                      "description": "The MIME type the upload was resolved to. Send the file with this type."
                    },
                    "ticket": {
                      "type": "string",
                      "description": "An opaque signed ticket naming the user, artist, storage path, file name, type and size. Pass it to Complete an upload within 15 minutes."
                    }
                  }
                },
                "example": {
                  "status": "ok",
                  "signedUrl": "https://example.supabase.co/storage/v1/object/upload/sign/lore-upload-staging/aab92f80-f9e1-4299-aa33-7dd85c8de5d3/7f8f0a3e-0c8a-4b65-9f0e-1b1c2d3e4f50_press-kit.pdf?token=…",
                  "contentType": "application/pdf",
                  "ticket": "eyJ1c2VySWQiOi…fQ.3b2a9c…"
                }
              }
            }
          },
          "400": {
            "description": "The body is missing a field, `artistId` isn't a UUID, `name` is blank or over 255 characters, `size` isn't a whole number from 1 to 10 MB, or the file type isn't supported.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "size": {
                    "summary": "A bad field",
                    "value": {
                      "status": "error",
                      "error": "Choose a file up to 10 MB per file."
                    }
                  },
                  "type": {
                    "summary": "An unsupported type",
                    "value": {
                      "status": "error",
                      "error": "File type not supported"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No token, an invalid or expired token, or no Music Nerd user for it (`Not signed in`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Not signed in"
                }
              }
            }
          },
          "403": {
            "description": "The user is neither the artist's claimant nor an admin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Not authorized for this artist"
                }
              }
            }
          },
          "500": {
            "description": "Storage could not issue a signed URL, or the token could not be checked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Could not prepare file storage. Please try again."
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "status",
          "error"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "error"
            ]
          },
          "error": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "privyBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Access token",
        "description": "The signed-in user's access token. Copy it at https://musicnerd.net/access after signing in. The user must be the artist's approved claimant or a Music Nerd admin."
      }
    }
  }
}
```
