Skip to main content

Method Signature

func (c *Client) Profile(ctx context.Context, runID string) (types.Profile, error)
Retrieves a specific profile by its run ID.

Parameters

ctx
context.Context
required
The context for the request, used for cancellation and timeouts.
runID
string
required
The unique identifier of the run to retrieve the profile for.

Returns

Profile
types.Profile
The profile object containing all profile data.
error
error
An error if the operation failed or the profile was not found, nil otherwise.

Example

package main

import (
    "context"
    "fmt"
    "log"
    
    "github.com/garnet-org/api/client"
)

func main() {
    // Initialize the client
    c := client.New("your-api-token")
    
    // Get a specific profile
    runID := "run_789012"
    
    profile, err := c.Profile(context.Background(), runID)
    if err != nil {
        log.Fatalf("Failed to get profile: %v", err)
    }
    
    fmt.Printf("Run ID: %s\n", profile.RunID)
    fmt.Printf("Agent ID: %s\n", profile.AgentID)
    fmt.Printf("Created at: %v\n", profile.CreatedAt)
    fmt.Printf("Updated at: %v\n", profile.UpdatedAt)
    fmt.Printf("Profile data: %+v\n", profile.Data)
}

Error Handling

Common errors:
  • 404 Not Found: The profile with the specified run ID does not exist
  • 401 Unauthorized: Invalid or missing authentication token
  • 403 Forbidden: Insufficient permissions to access the profile
profile, err := c.Profile(ctx, runID)
if err != nil {
    switch {
    case errors.Is(err, types.ErrProfileNotFound):
        fmt.Println("Profile not found")
    case errors.Is(err, types.ErrUnauthorized):
        fmt.Println("Authentication failed")
    default:
        fmt.Printf("Unexpected error: %v\n", err)
    }
    return
}

API Endpoint

GET /api/v1/profiles/{run_id}

Build docs developers (and LLMs) love