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

# Update User

PATCH https://your-agent-domain.com/api/v1/users/{user_id}
Content-Type: application/json

Updates a user's external_id and/or tags and upserts the persisted responder for the agent. Only provided fields are changed.

Reference: https://docs.apologist.ai/agent-api/api-reference/users/update-user

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: agent-api
  version: 1.0.0
paths:
  /users/{user_id}:
    patch:
      operationId: updateUser
      summary: Update User
      description: >-
        Updates a user's external_id and/or tags and upserts the persisted
        responder for the agent. Only provided fields are changed.
      tags:
        - users
      parameters:
        - name: user_id
          in: path
          description: The user's external id or internal id
          required: true
          schema:
            type: string
        - name: x-api-key
          in: header
          description: API key for authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The updated user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Users_updateUser_Response_200'
        '400':
          description: Bad Request - Unknown tag or responder not active on this agent
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden - Invalid or missing API key
          content:
            application/json:
              schema:
                description: Any type
        '404':
          description: User not found
          content:
            application/json:
              schema:
                description: Any type
        '422':
          description: Invalid request payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserUpdateRequest'
servers:
  - url: https://your-agent-domain.com/api/v1
    description: Production server
components:
  schemas:
    UserUpdateRequestTagsItems:
      oneOf:
        - type: string
        - type: integer
      title: UserUpdateRequestTagsItems
    UserUpdateRequest:
      type: object
      properties:
        external_id:
          type:
            - string
            - 'null'
          description: Your external identifier for the user.
        tags:
          type: array
          items:
            $ref: '#/components/schemas/UserUpdateRequestTagsItems'
          description: >-
            Applied tags as a mix of existing tag ids and/or default-language
            tag names. Unknown ids or names are rejected. Tags are mirror-owned
            and never created here.
        responder_id:
          type: integer
          description: >-
            Responder to persist for this user on the requesting agent. Must be
            active on the agent.
      description: >-
        Fields to update on the user. All fields are optional; only provided
        fields are changed.
      title: UserUpdateRequest
    TagRef:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
      title: TagRef
    User:
      type: object
      properties:
        id:
          type: string
          description: Internal user id (UUID).
        external_id:
          type:
            - string
            - 'null'
        team_id:
          type: integer
        created_at:
          type: string
        migrated_at:
          type:
            - string
            - 'null'
        migrated_to_user_id:
          type:
            - string
            - 'null'
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagRef'
        responder_id:
          type:
            - integer
            - 'null'
      title: User
    Users_updateUser_Response_200:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/User'
      title: Users_updateUser_Response_200
    Error:
      type: object
      properties:
        success:
          type: boolean
        errors:
          type: array
          items:
            type: string
      required:
        - success
        - errors
      title: Error
  securitySchemes:
    ApiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication
    BearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication

```

## Examples



**Request**

```json
{}
```

**Response**

```json
{
  "data": {
    "id": "string",
    "external_id": "string",
    "team_id": 1,
    "created_at": "string",
    "migrated_at": "string",
    "migrated_to_user_id": "string",
    "tags": [
      {
        "id": 1,
        "name": "string"
      }
    ],
    "responder_id": 1
  }
}
```

**SDK Code**

```typescript
import { ApologistAgentClient } from "apologist";

async function main() {
    const client = new ApologistAgentClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.users.updateUser("user_id", {});
}
main();

```

```python
from apologist import ApologistAgent

client = ApologistAgent(
    api_key="YOUR_API_KEY_HERE",
)

client.users.update_user(
    user_id="user_id",
)

```

```java
package com.example.usage;

import ai.apologist.AgentClient;
import ai.apologist.resources.users.requests.UserUpdateRequest;

public class Example {
    public static void main(String[] args) {
        AgentClient client = AgentClient
            .builder()
            .apiKey("YOUR_API_KEY_HERE")
            .build();

        client.users().updateUser(
            "user_id",
            UserUpdateRequest
                .builder()
                .build()
        );
    }
}
```

```ruby
require "apologist"

client = Apologist::AgentClient.new(api_key: "YOUR_API_KEY_HERE")

client.users.update_user(user_id: "user_id")

```

```csharp
using Apologist;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new AgentClient(
            apiKey: "YOUR_API_KEY_HERE"
        );

        await client.Users.UpdateUserAsync(
            new UserUpdateRequest {
                UserId = "user_id"
            }
        );
    }

}

```

```go
package example

import (
    context "context"

    apgsdkgo "github.com/apologist-project/apg-sdk-go"
    client "github.com/apologist-project/apg-sdk-go/client"
    option "github.com/apologist-project/apg-sdk-go/option"
)

func do() {
    client := client.NewApologistAgentClient(
        option.WithAPIKey(
            "YOUR_API_KEY_HERE",
        ),
    )
    request := &apgsdkgo.UserUpdateRequest{
        UserID: "user_id",
    }
    client.Users.UpdateUser(
        context.TODO(),
        request,
    )
}

```

```php
<?php

namespace Example;

use Apologist\AgentClient;
use Apologist\Users\Requests\UserUpdateRequest;

$client = new AgentClient(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->users->updateUser(
    'user_id',
    new UserUpdateRequest([]),
);

```

```swift
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://your-agent-domain.com/api/v1/users/user_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()
```