# Start Google Sheets OAuth

Create a single-use OAuth attempt for connect, add-file, or reconnect.

## Endpoint

`POST /api/v1/workspaces/{workspace_id}/google-sheets/oauth/start`

## Authentication

| Class | Authentication | Minimum role | API key |
| --- | --- | --- | --- |
| dashboard-session-api | Dashboard session cookie; POST mutations also require X-CX-Request: 1. | admin | Not allowed |

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | path | `string` | Yes | — |

## Request body

### application/json request schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | PermintaanMulaiOAuth | — | No | Yes | — | — |
| `connection_id` | `string or null` | — | — | Yes | No | — | — |
| `purpose` | `string` | — | — | No | Yes | "connect", "add_file", "reconnect" | — |

## Example

```bash
curl --request POST 'https://operade.ai/api/v1/workspaces/ws_demo/google-sheets/oauth/start' --cookie 'cx_session=YOUR_SESSION_COOKIE' --header 'X-CX-Request: 1' --header 'Content-Type: application/json' --data '{"purpose":"connect"}'
```

## Responses

| Status | Description | Content |
| --- | --- | --- |
| 4XX | Handled client error | application/json: `ErrorResponse` |
| 200 | Successful Response | application/json: `GoogleOAuthStartResponse` |

### 4XX application/json response schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | ErrorResponse | — | No | Yes | — | — |
| `error` | `object` | ErrorItem | — | No | Yes | — | — |
| `error.code` | `string` | — | — | No | Yes | — | — |
| `error.details` | `object` | — | — | No | No | — | — |
| `error.message` | `string` | — | — | No | Yes | — | — |

### 200 application/json response schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | GoogleOAuthStartResponse | — | No | Yes | — | — |
| `authorization_url` | `string` | — | — | No | Yes | — | — |

### Response example

```json
{
  "authorization_url": "https://accounts.google.com/o/oauth2/v2/auth?..."
}
```

## Errors

Reviewed common and route-declared errors are summarized here; the list is not exhaustive. Start with the [distributed error index](/docs/reference/api/errors) to find each code's canonical domain page.

| Status | Code | Description |
| --- | --- | --- |
| 401 | `unauthenticated` | Authentication is missing, invalid, or revoked. |
| 403 | `forbidden` | Only a workspace admin or owner can start Google OAuth. |
| 404 | `not_found` | The requested Google connection was not found. |
| 409 | `conflict` | The Google connection status does not allow this OAuth purpose. |
| 422 | `validation_failed` | Purpose and connection ID do not form a valid OAuth request. |
| 503 | `google_integration_not_configured` | The Google Sheets integration is disabled or incomplete. |

## Related operations

- [Complete Google Sheets OAuth](/docs/api-reference/google-sheets/complete-google-sheets-oauth) — `GET /api/v1/oauth/google-sheets/callback`
- [Get Google Sheet grant metadata](/docs/api-reference/google-sheets/get-google-sheet-grant-metadata) — `GET /api/v1/workspaces/{workspace_id}/google-sheets/grants/{grant_id}/metadata`
- [List Google Sheets connections](/docs/api-reference/google-sheets/list-google-sheets-connections) — `GET /api/v1/workspaces/{workspace_id}/google-sheets/connections`
