# Approve or deny an agent

Source: https://docs.musicnerd.net/api-reference/oauth/post-consent

Approve or deny an agent

## POST /api/oauth/consent

Full OpenAPI specification: https://docs.musicnerd.net/spec/oauth.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: OAuth",
    "version": "1.0.0",
    "description": "How agents connect to the MCP server with OAuth: the discovery documents an MCP client reads, and the member's list of connected agents."
  },
  "servers": [
    {
      "url": "https://api.musicnerd.net",
      "description": "Production"
    },
    {
      "url": "https://musicnerd-api-staging.vercel.app",
      "description": "Staging (staging database)"
    }
  ],
  "paths": {
    "/api/oauth/consent": {
      "post": {
        "summary": "Approve or deny an agent",
        "operationId": "postOAuthConsent",
        "security": [
          {
            "privyBearer": []
          }
        ],
        "description": "Records the signed-in user's decision on an authorization request and returns where to send the browser. Approving connects the agent and adds a single-use code, valid for 60 seconds; denying adds `error=access_denied`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "The query of the authorization request, plus the decision.",
                "required": [
                  "response_type",
                  "client_id",
                  "redirect_uri",
                  "code_challenge",
                  "code_challenge_method",
                  "decision"
                ],
                "properties": {
                  "response_type": {
                    "type": "string",
                    "enum": [
                      "code"
                    ]
                  },
                  "client_id": {
                    "type": "string"
                  },
                  "redirect_uri": {
                    "type": "string"
                  },
                  "code_challenge": {
                    "type": "string"
                  },
                  "code_challenge_method": {
                    "type": "string",
                    "enum": [
                      "S256"
                    ]
                  },
                  "state": {
                    "type": "string"
                  },
                  "scope": {
                    "type": "string"
                  },
                  "resource": {
                    "type": "string"
                  },
                  "decision": {
                    "type": "string",
                    "enum": [
                      "approve",
                      "deny"
                    ]
                  }
                }
              },
              "example": {
                "response_type": "code",
                "client_id": "2f6c1d0e-8a4b-4c47-9a51-3e0f7b9d2c18",
                "redirect_uri": "http://127.0.0.1:33418/callback",
                "code_challenge": "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM",
                "code_challenge_method": "S256",
                "state": "af0ifjsldkj",
                "decision": "approve"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Where to send the browser: the client's redirect URI with `code`, `state` and `iss`, or with `error=access_denied` and `state`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "redirectUrl"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "redirectUrl": {
                      "type": "string",
                      "format": "uri"
                    }
                  }
                },
                "example": {
                  "status": "ok",
                  "redirectUrl": "http://127.0.0.1:33418/callback?code=mn_code_EXAMPLE&state=af0ifjsldkj&iss=https%3A%2F%2Fapi.musicnerd.net%2Fapi%2Foauth"
                }
              }
            }
          },
          "400": {
            "description": "The request is invalid: unknown client, unregistered redirect, missing PKCE or no decision.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "error",
                  "error": "Invalid authorization request"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/NotSignedIn"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "status",
          "error"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "error"
            ]
          },
          "error": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "NotSignedIn": {
        "description": "No token, or an invalid or expired one.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "error",
              "error": "Not signed in"
            }
          }
        }
      },
      "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": {
      "privyBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Access token",
        "description": "A Privy access token for a signed-in Music Nerd user, as musicnerd.net holds it."
      }
    }
  }
}
```
