Thread: Update v1

The Threads API allows you to update existing conversation threads. This endpoint helps you manage thread metadata for better organization and filtering of your conversational applications.


Generate a User/Org API key

You will need to generate an API key to authenticate your requests. For more information, visit the User/Org API key documentation.


POST/v1/threads/{threadId}

Update an existing thread

Update an existing thread's metadata.

Headers

  • Name
    Content-Type
    Type
    string
    Required
    Required
    Description

    Request content type. Needs to be application/json

  • Name
    Authorization
    Type
    string
    Required
    Required
    Description

    Replace LANGBASE_API_KEY with your User/Org API key


Path Parameters

  • Name
    threadId
    Type
    string
    Required
    Required
    Description

    The ID of the thread to update.


Body Parameters

  • Name
    metadata
    Type
    Record<string, string>
    Required
    Required
    Description

    Key-value pairs to update or add to the thread's metadata.

Usage example

Install the SDK

npm i langbase

Environment variables

.env file

LANGBASE_API_KEY="<USER/ORG-API-KEY>"

Update an existing thread

Update thread metadata

POST
/v1/threads/{threadId}
import { Langbase } from 'langbase';

const langbase = new Langbase({
  apiKey: process.env.LANGBASE_API_KEY // Your User/Org API key
});

async function main() {
  const threadId = "thread_abc123xyz456";

  const updatedThread = await langbase.threads.update({
    threadId: threadId,
    metadata: {
      status: "resolved",
      priority: "high"
    }
  });

  console.log('Thread updated:', updatedThread.id);
  return updatedThread;
}

main();

Response

The response is a ThreadsBaseResponse object with information about the updated thread.

  • Name
    id
    Type
    string
    Description

    The unique identifier for the thread.

  • Name
    object
    Type
    string
    Description

    The type of object. Always "thread".

  • Name
    created_at
    Type
    number
    Description

    The Unix timestamp (in seconds) for when the thread was created.

  • Name
    metadata
    Type
    Record<string, string>
    Description

    The updated metadata associated with the thread.

Response Example

{
 "id": "thread_abc123xyz456",
 "object": "thread",
 "created_at": 1714322048,
 "metadata": {
   "userId": "user123",
   "topic": "support",
   "status": "resolved",
   "priority": "high"
 }
}