# Save or regenerate the About

Source: https://docs.musicnerd.net/api-reference/artist-bio/update-about

Save or regenerate the About

## PUT /api/artistBio/{id}

Full OpenAPI specification: https://docs.musicnerd.net/spec/artist-bio.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 bio",
    "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/artistBio/{id}": {
      "put": {
        "summary": "Save or regenerate the About",
        "operationId": "putArtistBio",
        "security": [
          {
            "privyBearer": []
          }
        ],
        "description": "Saves the About the artist wrote, or with `regenerate: true` rewrites it from the artist's Lore, for the approved claimant or an admin. Both the old and the new text are kept in the bio history, and a pinned bio is never replaced.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The artist's ID (a UUID).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "aab92f80-f9e1-4299-aa33-7dd85c8de5d3"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "bio": {
                    "type": "string",
                    "maxLength": 10000,
                    "description": "The About to save. Required unless `regenerate` is true; at most 10,000 characters."
                  },
                  "regenerate": {
                    "type": "boolean",
                    "default": false,
                    "description": "Rewrite the About from the Lore document instead of saving `bio`."
                  }
                }
              },
              "examples": {
                "save": {
                  "summary": "Save an edit",
                  "value": {
                    "bio": "Bio Ritmo is a 10-piece salsa band from Richmond, Virginia."
                  }
                },
                "regenerate": {
                  "summary": "Rewrite from Lore",
                  "value": {
                    "regenerate": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved, or regenerated. A regeneration returns the About that is now saved and a message saying whether it changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BioUpdate"
                },
                "examples": {
                  "saved": {
                    "summary": "An edit was saved",
                    "value": {
                      "status": "ok",
                      "message": "Bio updated"
                    }
                  },
                  "regenerated": {
                    "summary": "The About was regenerated",
                    "value": {
                      "status": "ok",
                      "message": "Bio regenerated",
                      "bio": "Bio Ritmo is a 10-piece salsa band from Richmond, Virginia, playing since 1991."
                    }
                  },
                  "unchanged": {
                    "summary": "Pinned, or the Lore produced the same text",
                    "value": {
                      "status": "ok",
                      "message": "About unchanged. A pinned bio stays locked until you unpin it; otherwise the saved Lore produced the same text.",
                      "bio": "Bio Ritmo is a 10-piece salsa band from Richmond, Virginia."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`id` isn't a UUID, the body isn't JSON, `bio` is missing or blank without `regenerate`, or `bio` is over 10,000 characters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid": {
                    "summary": "No bio",
                    "value": {
                      "status": "error",
                      "error": "Invalid bio"
                    }
                  },
                  "tooLong": {
                    "summary": "Over the limit",
                    "value": {
                      "status": "error",
                      "error": "Bio must be 10000 characters or fewer"
                    }
                  }
                }
              }
            }
          },
          "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 your artist"
                }
              }
            }
          },
          "404": {
            "description": "`regenerate: true` for an artist that no longer exists.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Artist not found"
                }
              }
            }
          },
          "408": {
            "description": "`regenerate: true`: the model did not answer in time. The existing About is kept.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "About generation timed out. Please try again. Your existing About has been kept."
                }
              }
            }
          },
          "409": {
            "description": "`regenerate: true`: no Lore document yet (`code: \"LORE_REQUIRED\"`), or the bio changed, was pinned or the claim changed while the About was being written.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BioError"
                },
                "example": {
                  "status": "error",
                  "code": "LORE_REQUIRED",
                  "error": "Build your Lore document before generating About. Your existing About has been kept."
                }
              }
            }
          },
          "500": {
            "description": "The write failed, the claim changed during the save, or an edit that differs from a pinned bio was refused.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "pinned": {
                    "summary": "An edit while a bio is pinned",
                    "value": {
                      "status": "error",
                      "error": "Unpin your bio before editing it. Your saved version will be kept."
                    }
                  },
                  "failed": {
                    "summary": "The write failed",
                    "value": {
                      "status": "error",
                      "error": "Error updating bio"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "BioUpdate": {
        "type": "object",
        "required": [
          "status",
          "message"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok"
            ]
          },
          "message": {
            "type": "string"
          },
          "bio": {
            "type": "string",
            "description": "After a regeneration: the About now saved."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "status",
          "error"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "error"
            ]
          },
          "error": {
            "type": "string"
          }
        }
      },
      "BioError": {
        "type": "object",
        "required": [
          "status",
          "error"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "error"
            ]
          },
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "LORE_REQUIRED"
            ],
            "description": "Present when the About cannot be generated because there is no Lore document."
          }
        }
      }
    },
    "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. Each operation says who may call it: any signed-in user, or the artist's approved claimant or a Music Nerd admin."
      }
    }
  }
}
```
