Teams API

Manage team channels synced from WooCommerce Teams. Archive, restore, and sync team membership.

The Teams API allows external systems (primarily WooCommerce Teams) to manage team channels in Loop.

Archive / Restore Team

Archive a team channel or restore an archived team.

Endpoint

POST /api/v1/integration/teams/{wpTeamId}/archive

Path Parameters

ParameterTypeDescription
wpTeamIdintegerThe WordPress/WooCommerce team ID

Request Body

{
  "action": "archive" | "restore",
  "visibility": "hidden" | "readonly"
}

Body Parameters

ParameterTypeRequiredDescription
actionstringYesEither "archive" to archive or "restore" to restore the team channel
visibilitystringNoArchive visibility mode. Only used when action is "archive". Defaults to "hidden"

Archive Visibility Modes

ModeBehavior
hiddenTeam channel is completely hidden from members
readonlyTeam channel is visible but members cannot post new messages

Example Request - Archive Team as Read-Only

curl -X POST https://your-domain.com/api/v1/integration/teams/42/archive \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "archive",
    "visibility": "readonly"
  }'

Example Request - Restore Team

curl -X POST https://your-domain.com/api/v1/integration/teams/42/archive \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "restore"
  }'

Success Response

{
  "success": true,
  "message": "Team archived successfully"
}

Error Responses

Invalid Team ID (400)

{
  "error": {
    "code": "invalid_team_id",
    "message": "WordPress team ID must be a positive integer"
  }
}

Team Not Found (400)

{
  "error": {
    "code": "team_not_found",
    "message": "Team with WordPress ID 42 not found"
  }
}

Sync Team

Create or update a team channel with full team data.

Endpoint

POST /api/v1/integration/teams

Request Body

{
  "wp_team_id": 42,
  "name": "Premium Subscribers",
  "slug": "premium-subscribers",
  "owner_wp_id": 123,
  "member_wp_ids": [123, 456, 789],
  "status": "active"
}

Body Parameters

ParameterTypeRequiredDescription
wp_team_idintegerYesWordPress/WooCommerce team ID
namestringYesTeam name (used as channel name)
slugstringNoURL-friendly slug (auto-generated if not provided)
owner_wp_idintegerYesWordPress user ID of the team owner
member_wp_idsinteger[]NoArray of WordPress user IDs for team members
statusstringNoTeam status: "active" or "inactive"

Success Response

{
  "success": true,
  "created": true,
  "channel": {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "name": "Premium Subscribers",
    "slug": "premium-subscribers",
    "privacy": "private",
    "channel_type": "channel",
    "is_archived": false
  }
}

Add Team Member

Add a member to an existing team channel.

Endpoint

POST /api/v1/integration/teams/{wpTeamId}/members

Request Body

{
  "wp_user_id": 456
}

Success Response

{
  "success": true,
  "message": "Member added to team"
}

Remove Team Member

Remove a member from a team channel.

Endpoint

DELETE /api/v1/integration/teams/{wpTeamId}/members/{wpUserId}

Success Response

{
  "success": true,
  "message": "Member removed from team"
}

Error Response - Cannot Remove Owner

{
  "error": {
    "code": "cannot_remove_owner",
    "message": "Cannot remove the team owner from the channel"
  }
}

Change Team Owner

Transfer team ownership to another member.

Endpoint

PUT /api/v1/integration/teams/{wpTeamId}/owner

Request Body

{
  "new_owner_wp_id": 789
}

Success Response

{
  "success": true,
  "message": "Team ownership transferred"
}

WooCommerce Integration Notes

Webhook Events

The Teams API is designed to be called from WooCommerce webhook events:

WooCommerce EventAPI Action
team_createdPOST /teams (sync)
team_updatedPOST /teams (sync)
team_deletedPOST /teams/{id}/archive
team_member_addedPOST /teams/{id}/members
team_member_removedDELETE /teams/{id}/members/{userId}

User Mapping

Team members are mapped to Loop users via the wp_user_id stored in user metadata. Users must exist in Loop before they can be added as team members.