> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://onepin.ai/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://onepin.ai/docs/_mcp/server.

# Update Invite Role

PATCH https://api.onepin.ai/api/v1/workspaces/{ws_id}/invites/{invite_id}
Content-Type: application/json

Change the role on a pending (not yet accepted) invite. Admin only.

Updates the role the invitee will receive when they accept. Only pending
invites can be updated — attempting to update an accepted, revoked, or
expired invite returns 409. The invitee is not notified of the role
change; the updated role takes effect when they accept.

Reference: https://onepin.ai/docs/reference/api-reference/workspace-members/update-invite-role-api-v-1-workspaces-ws-id-invites-invite-id-patch

## Authentication

- `Authorization` header (bearer token, required) — Clerk JWT token

## Servers

- `https://api.onepin.ai` (prod, default)
- `https://dev-api.onepin.ai` (dev)

## Request

### Path parameters

- `ws_id` (string, required)
- `invite_id` (string, required)

### Body (application/json)

This endpoint expects a WorkspaceMemberRoleUpdate.

- `role` (enum, required) — New role to assign: `admin`, `editor`, or `viewer`.
  - Allowed values: `admin`, `editor`, `viewer`

## Response

### 200

Successful Response

- `data` (WorkspaceInviteOut, required)
- `meta` (Meta, required)

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### WorkspaceInviteOut

- `id` (string, required) — Unique invite ID.
- `email` (string, required) — Email address the invite was sent to.
- `role` (string, required) — Role the invitee will receive on acceptance: `admin`, `editor`, or `viewer`.
- `status` (string, required) — Current invite status: `pending`, `accepted`, `revoked`, or `expired`.
- `expires_at` (datetime, required) — When the invite expires (UTC). Invites have a 14-day TTL from creation.
- `invited_by` (string, required) — User ID of the admin who created the invite.
- `created_at` (datetime, required) — When the invite was created (UTC).

### Meta

- `request_id` (string, required)
- `timestamp` (datetime, required)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `input` (any, optional)
- `ctx` (ValidationErrorCtx, optional)

### ValidationErrorLocItems

### ValidationErrorCtx

## Examples

**Request**

```json
{
  "role": "editor"
}
```

**Response**

```json
{
  "data": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "email": "invitee@example.com",
    "role": "editor",
    "status": "pending",
    "expires_at": "2024-01-29T09:30:00Z",
    "invited_by": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "created_at": "2024-01-15T09:30:00Z"
  },
  "meta": {
    "request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "timestamp": "2024-01-15T09:30:00Z"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.onepin.ai/api/v1/workspaces/ws_id/invites/invite_id"

payload = { "role": "editor" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.onepin.ai/api/v1/workspaces/ws_id/invites/invite_id';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"role":"editor"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.onepin.ai/api/v1/workspaces/ws_id/invites/invite_id"

	payload := strings.NewReader("{\n  \"role\": \"editor\"\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.onepin.ai/api/v1/workspaces/ws_id/invites/invite_id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"role\": \"editor\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.onepin.ai/api/v1/workspaces/ws_id/invites/invite_id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"role\": \"editor\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.onepin.ai/api/v1/workspaces/ws_id/invites/invite_id', [
  'body' => '{
  "role": "editor"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.onepin.ai/api/v1/workspaces/ws_id/invites/invite_id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"role\": \"editor\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["role": "editor"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.onepin.ai/api/v1/workspaces/ws_id/invites/invite_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```