# Update a source

Source: https://docs.musicnerd.net/api-reference/vault/update-source

Update a source

## PATCH /api/artist/{id}/knowledge/sources/{sourceId}

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",
    "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/{id}/knowledge/sources/{sourceId}": {
      "patch": {
        "summary": "Update a source",
        "operationId": "updateArtistSource",
        "security": [
          {
            "privyBearer": []
          }
        ],
        "description": "Approves or rejects one of the artist's sources, or changes its type. A status change starts a Lore refresh, so the artist's Lore follows the decision.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The artist's ID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "sourceId",
            "in": "path",
            "required": true,
            "description": "The source's ID. It must belong to the artist.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "minProperties": 1,
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "approved",
                      "rejected"
                    ],
                    "description": "The review decision."
                  },
                  "expectedStatus": {
                    "type": "string",
                    "enum": [
                      "pending"
                    ],
                    "description": "Apply `status` only if the source is still pending. Send it from a review queue so a second reviewer doesn't overwrite the first. Needs `status`."
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "article",
                      "interview",
                      "review",
                      "profile",
                      "document",
                      "image",
                      "audio",
                      "video",
                      "data",
                      "social",
                      "website",
                      "music"
                    ],
                    "description": "The source's type."
                  }
                }
              },
              "examples": {
                "approve": {
                  "summary": "Approve from a review queue",
                  "value": {
                    "status": "approved",
                    "expectedStatus": "pending"
                  }
                },
                "type": {
                  "summary": "Change the type",
                  "value": {
                    "type": "interview"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The source was updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    }
                  }
                },
                "example": {
                  "status": "ok"
                }
              }
            }
          },
          "400": {
            "description": "`id` or `sourceId` isn't a UUID, or the body has neither `status` nor `type`, an unknown value, or `expectedStatus` without `status`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "badId": {
                    "summary": "`id` isn't a UUID",
                    "value": {
                      "status": "error",
                      "error": "artistId must be a UUID"
                    }
                  },
                  "badBody": {
                    "summary": "A bad body",
                    "value": {
                      "status": "error",
                      "error": "Send status or type"
                    }
                  },
                  "badSource": {
                    "summary": "`sourceId` isn't a UUID",
                    "value": {
                      "status": "error",
                      "error": "sourceId must be a UUID"
                    }
                  }
                }
              }
            }
          },
          "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 approved claimant nor an admin, or the artist's claim changed during the request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "notYours": {
                    "summary": "Not the claimant or an admin",
                    "value": {
                      "status": "error",
                      "error": "Not your artist"
                    }
                  },
                  "ownershipChanged": {
                    "summary": "The claim changed during the request",
                    "value": {
                      "status": "error",
                      "error": "Artist ownership changed; this operation was cancelled."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No source with that ID belongs to the artist.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Source not found"
                }
              }
            }
          },
          "409": {
            "description": "`expectedStatus` was sent and the source has already been reviewed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "This Lore source was already reviewed. Refresh the queue to see its current status."
                }
              }
            }
          },
          "500": {
            "description": "The source could not be updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Failed to update source"
                }
              }
            }
          }
        }
      }
    }
  },
  "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."
      }
    }
  }
}
```
