Skip to main content
GET
https://api-dev.weir.ai/
/
org
/
teams
curl -X GET 'https://api.weir.ai/org/teams?page=1&limit=10' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'x-source: console'
{
  "data": {
    "teams": [
      {
        "teamId": "team_123456789",
        "name": "Development Team",
        "memberCount": 5,
        "createdAt": "2024-01-15T10:30:00Z",
        "status": "active"
      },
      {
        "teamId": "team_987654321",
        "name": "Marketing Team",
        "memberCount": 3,
        "createdAt": "2024-01-20T14:15:00Z",
        "status": "active"
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 10,
      "total": 2,
      "totalPages": 1
    }
  },
  "message": "Teams retrieved successfully",
  "status": "success"
}

Get Teams

Retrieve a paginated list of all teams in your organization with their basic information.
curl -X GET 'https://api.weir.ai/org/teams?page=1&limit=10' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'x-source: console'
{
  "data": {
    "teams": [
      {
        "teamId": "team_123456789",
        "name": "Development Team",
        "memberCount": 5,
        "createdAt": "2024-01-15T10:30:00Z",
        "status": "active"
      },
      {
        "teamId": "team_987654321",
        "name": "Marketing Team",
        "memberCount": 3,
        "createdAt": "2024-01-20T14:15:00Z",
        "status": "active"
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 10,
      "total": 2,
      "totalPages": 1
    }
  },
  "message": "Teams retrieved successfully",
  "status": "success"
}

Authentication

This endpoint requires Console API authentication with bearer token and x-source: console header.
Authorization
string
required
Bearer token for authentication. Format: Bearer YOUR_ACCESS_TOKEN
x-source
string
required
Source identifier. Must be set to console for all Console API requests.

Query Parameters

page
integer
default:"1"
Page number for pagination. Must be a positive integer.
limit
integer
default:"10"
Number of teams per page. Range: 1-100.

Response Fields

data
object
required
Teams data object containing the list of teams and pagination information.
message
string
required
Human-readable message describing the result of the operation.
status
string
required
Operation status. Always “success” for successful requests.

Error Responses

{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or expired token",
    "details": "The provided access token is invalid or has expired"
  },
  "status": "error"
}
Causes:
  • Missing or invalid access token
  • Expired access token
  • Missing x-source header
{
  "error": {
    "code": "FORBIDDEN",
    "message": "Insufficient permissions",
    "details": "You do not have permission to view teams in this organization"
  },
  "status": "error"
}
Causes:
  • User lacks team viewing permissions
  • User is not a member of the organization
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid pagination parameters",
    "details": {
      "page": "Page must be a positive integer",
      "limit": "Limit must be between 1 and 100"
    }
  },
  "status": "error"
}
Causes:
  • Invalid page number (negative or zero)
  • Invalid limit value (outside 1-100 range)

Usage Examples

const getTeams = async (accessToken, page = 1, limit = 10) => {
  try {
    const response = await fetch(`https://api.weir.ai/org/teams?page=${page}&limit=${limit}`, {
      method: 'GET',
      headers: {
        'Authorization': `Bearer ${accessToken}`,
        'x-source': 'console'
      }
    });
    
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }
    
    const data = await response.json();
    return data.data;
  } catch (error) {
    console.error('Get teams error:', error);
    throw error;
  }
};

// Usage
const teamsData = await getTeams('your_access_token', 1, 20);
console.log('Teams:', teamsData.teams);
console.log('Total teams:', teamsData.pagination.total);

Pagination Examples

// Get first page with default limit
const firstPage = await getTeams(accessToken);

// Get second page with 20 items per page
const secondPage = await getTeams(accessToken, 2, 20);
async function getAllTeams(accessToken) {
  const allTeams = [];
  let page = 1;
  let hasMore = true;
  
  while (hasMore) {
    const data = await getTeams(accessToken, page, 50);
    allTeams.push(...data.teams);
    
    hasMore = page < data.pagination.totalPages;
    page++;
  }
  
  return allTeams;
}
// Client-side filtering example
const teamsData = await getTeams(accessToken);
const activeTeams = teamsData.teams.filter(team => team.status === 'active');
const largeTeams = teamsData.teams.filter(team => team.memberCount > 5);

Best Practices

  • Use reasonable page limits to avoid large responses
  • Implement client-side caching for frequently accessed data
  • Consider implementing search and filtering on the client side
  • Handle pagination parameter validation errors
  • Implement retry logic for transient failures
  • Provide fallback UI for empty team lists
Pro Tip: Use pagination to efficiently load teams in your UI. Start with a reasonable page size (10-20) and implement “Load More” functionality for better user experience.