# Save the artist's link order

Source: https://docs.musicnerd.net/api-reference/artist-links/link-order

Save the artist's link order

## PUT /api/artist/link-order

Full OpenAPI specification: https://docs.musicnerd.net/spec/artist-links.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 links",
    "version": "1.0.0",
    "description": "Writing, ordering, checking and reviewing the platform links on an artist's profile."
  },
  "servers": [
    {
      "url": "https://musicnerd-api.vercel.app",
      "description": "Production"
    },
    {
      "url": "https://musicnerd-api-staging.vercel.app",
      "description": "Staging (staging database)"
    }
  ],
  "paths": {
    "/api/artist/link-order": {
      "put": {
        "summary": "Save the artist's link order",
        "operationId": "putArtistLinkOrder",
        "security": [
          {
            "privyBearer": []
          }
        ],
        "description": "Saves the order of the artist's `links` or `support` section, for the claimant or an admin. Every name must be `spotify`, `deezer` or a supported platform; the next profile render uses the order.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "artistId",
                  "section",
                  "order"
                ],
                "properties": {
                  "artistId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "section": {
                    "type": "string",
                    "enum": [
                      "links",
                      "support"
                    ],
                    "description": "Which link group was reordered."
                  },
                  "order": {
                    "type": "array",
                    "maxItems": 100,
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 80
                    },
                    "description": "Platform names (urlmap `siteName`s) in display order, no duplicates."
                  }
                }
              },
              "example": {
                "artistId": "6cb3d81a-3d02-4c57-a711-bb7902a9af1b",
                "section": "links",
                "order": [
                  "spotify",
                  "instagram",
                  "youtube"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "status": "ok",
                  "success": true
                }
              }
            }
          },
          "400": {
            "description": "The body is not a valid link order (`Invalid link order`), or a name is not a known platform (`Unknown platform`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Invalid link order"
                }
              }
            }
          },
          "401": {
            "description": "No valid access token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Not signed in"
                }
              }
            }
          },
          "403": {
            "description": "The user is not the artist's approved claimant or an admin (`Not authorized for this artist`), or the claim changed while saving (`Artist ownership changed; this operation was cancelled.`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Not authorized for this artist"
                }
              }
            }
          },
          "404": {
            "description": "No artist has that id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Artist not found"
                }
              }
            }
          },
          "500": {
            "description": "The order could not be saved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Could not save link order"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Success": {
        "type": "object",
        "required": [
          "status",
          "success"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok"
            ]
          },
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "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. Link writes need the artist's approved claimant or a Music Nerd admin; `removeArtistData` accepts any whitelisted user too."
      }
    }
  }
}
```
