# Upload a profile image

Source: https://docs.musicnerd.net/api-reference/artist-images/upload-profile-image

Upload a profile image

## POST /api/artist/profile-image

Full OpenAPI specification: https://docs.musicnerd.net/spec/artist-images.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: artist images",
    "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/artist/profile-image": {
      "post": {
        "summary": "Upload a profile image",
        "operationId": "uploadProfileImage",
        "security": [
          {
            "privyBearer": []
          }
        ],
        "description": "Uploads a PNG, JPEG or WebP of at most 5 MB as the artist's profile photo and returns its public URL. The file's bytes must match its declared type.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file",
                  "artistId"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "The image: `image/png`, `image/jpeg` or `image/webp`, at most 5 MB."
                  },
                  "artistId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The artist's ID (a UUID)."
                  }
                }
              },
              "example": {
                "artistId": "aab92f80-f9e1-4299-aa33-7dd85c8de5d3"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The image is stored and the artist's photo points at it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProfileImageUploaded"
                },
                "example": {
                  "status": "ok",
                  "success": true,
                  "imagePath": "https://example.supabase.co/storage/v1/object/public/vault-files/profile-images/aab92f80-f9e1-4299-aa33-7dd85c8de5d3_1761000000000.png"
                }
              }
            }
          },
          "400": {
            "description": "`file` or `artistId` is missing, `artistId` isn't a UUID, the file is over 5 MB, its type isn't PNG, JPEG or WebP, or its bytes don't match the declared type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing": {
                    "summary": "A field is missing",
                    "value": {
                      "status": "error",
                      "error": "File and artistId are required"
                    }
                  },
                  "invalidArtist": {
                    "summary": "artistId isn't a UUID",
                    "value": {
                      "status": "error",
                      "error": "Invalid artist"
                    }
                  },
                  "tooLarge": {
                    "summary": "Over 5 MB",
                    "value": {
                      "status": "error",
                      "error": "Image too large (max 5MB)"
                    }
                  },
                  "wrongType": {
                    "summary": "Not PNG, JPEG or WebP",
                    "value": {
                      "status": "error",
                      "error": "Only PNG, JPEG, and WebP images are supported"
                    }
                  },
                  "magicBytes": {
                    "summary": "The bytes aren't the declared type",
                    "value": {
                      "status": "error",
                      "error": "Image content does not match declared type"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No token, an invalid or expired token, or no Music Nerd user for it.",
            "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": "The storage upload failed, the token could not be checked, or something else failed after the checks passed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "storage": {
                    "summary": "Storage refused the upload",
                    "value": {
                      "status": "error",
                      "error": "Failed to upload image to storage"
                    }
                  },
                  "other": {
                    "summary": "Any other failure",
                    "value": {
                      "status": "error",
                      "error": "Failed to upload image"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Image storage isn't configured on this server (`SUPABASE_URL` / `SUPABASE_SERVICE_ROLE_KEY` missing).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Image storage is not configured on this server (missing SUPABASE_URL / SUPABASE_SERVICE_ROLE_KEY)."
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ProfileImageUploaded": {
        "type": "object",
        "required": [
          "status",
          "success",
          "imagePath"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok"
            ]
          },
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "imagePath": {
            "type": "string",
            "format": "uri",
            "description": "The stored image's public URL, now the artist's `customImage`."
          }
        }
      },
      "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."
      }
    }
  }
}
```
