# Approve a contributor's submissions

Source: https://docs.musicnerd.net/api-reference/admin/approve-submissions

Approve a contributor's submissions

## POST /api/admin/users/{id}/submissions/approve

Full OpenAPI specification: https://docs.musicnerd.net/spec/admin.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: admin",
    "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/admin/users/{id}/submissions/approve": {
      "post": {
        "summary": "Approve a contributor's submissions",
        "operationId": "approveContributorSubmissions",
        "security": [
          {
            "adminBearer": []
          }
        ],
        "description": "Approves up to 10 of the user's pending submissions from [the list](/api-reference/admin/pending-submissions), and returns how many were approved, skipped (already reviewed, or not this user's) and failed. Approved Lore sources queue a Lore refresh for their artist; `warning` says when one could not start.",
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "items"
                ],
                "properties": {
                  "items": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 10,
                    "items": {
                      "type": "object",
                      "required": [
                        "id",
                        "type"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "link",
                            "lore",
                            "upload"
                          ]
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "items": [
                  {
                    "id": "5f2d0c1e-8a7b-4c3d-9e1f-0a2b3c4d5e6f",
                    "type": "link"
                  },
                  {
                    "id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
                    "type": "lore"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The counts. A failed item stays pending for individual review.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "approved",
                    "skipped",
                    "failed"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "approved": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "skipped": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "failed": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "warning": {
                      "type": "string",
                      "description": "Present when a Lore refresh could not start."
                    }
                  }
                },
                "example": {
                  "status": "ok",
                  "approved": 2,
                  "skipped": 0,
                  "failed": 0
                }
              }
            }
          },
          "400": {
            "description": "`id` isn't a UUID, or `items` isn't 1 to 10 submissions.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Invalid approval selection"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/NotSignedIn"
          },
          "403": {
            "$ref": "#/components/responses/NotAdmin"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "userId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "The contributor's user ID (a UUID).",
        "schema": {
          "type": "string",
          "format": "uuid"
        },
        "example": "0b1e4c2a-7f3d-4a58-9c61-2d8e5f7a9b10"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "status",
          "error"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "error"
            ]
          },
          "error": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "NotSignedIn": {
        "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"
            }
          }
        }
      },
      "NotAdmin": {
        "description": "The user is not an admin.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "error",
              "error": "Forbidden"
            }
          }
        }
      },
      "InternalError": {
        "description": "The database could not be read or written.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "error",
              "error": "Internal server error"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "adminBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Access token",
        "description": "A Music Nerd admin's access token. Copy it at https://musicnerd.net/access after signing in. A signed-in user who is not an admin gets 403."
      }
    }
  }
}
```
