Aller au contenu
Ressource · Workspace

Memberships

A membership gives a user a role in a workspace.

memberships:readmemberships:write
MéthodeCheminRésumé
GET…/membershipsList workspace memberships
PATCH…/memberships/{membershipId}Update a workspace membership
POST…/memberships/{membershipId}/disableDisable a workspace membership

Les chemins commencent par /workspaces/{workspaceId}. Les endpoints GET demandent memberships:read, les autres memberships:write.

L’objet Membership

firestoreIdstringobligatoire

ID of the membership, the same as the user ID of the member.

workspaceIdstringobligatoire

ID of the workspace.

userIdstringobligatoire

ID of the user.

displayNamestringobligatoire
emailstringemailobligatoire
photoUrlstringuri
rolestringobligatoire

Role of the user, which sets its permissions in a workspace (ws.) or a billing account (ba.).

  • ws.owner

    Owner of the workspace, with every permission, including deleting the workspace and managing owners.

  • ws.admin

    Administrator of the workspace, with every permission except managing owners and deleting the workspace or its files.

  • ws.member

    Member of the workspace, who works on its transactions, invoices, payments and accounting but manages neither its bank accounts nor its members.

  • ws.viewer

    Viewer of the workspace, a role that grants no permission.

  • ws.support

    Sway support access, granted when you invite the Sway bot.

  • ba.owner

    Owner of the billing account, with every permission, including deleting it.

  • ba.admin

    Administrator of the billing account, who reads and updates it but cannot delete it.

  • ba.member

    Member of the billing account, who can only read it.

Afficher les 8 champs
activationobjectobligatoire

Whether the resource is enabled, and when and by whom it was last enabled or disabled.

Afficher les 3 champs enfants
enabledbooleanobligatoire

Whether the resource is enabled.

updateDateTimestringdate-timeobligatoire

Date and time when enabled was last set.

updatedBystring

ID of the user who last set enabled, when recorded.

L’objet Membership
{
  "firestoreId": "Xq3vT9mB2kLpR7sN4wYc8dZf1aHj",
  "workspaceId": "Wk7fQ2xR9bLm4tZp8sNv",
  "userId": "Xq3vT9mB2kLpR7sN4wYc8dZf1aHj",
  "displayName": "string",
  "email": "anna.meier@example.com",
  "photoUrl": "https://example.com",
  "role": "ws.owner",
  "activation": {
    "enabled": true,
    "updateDateTime": "2026-03-02T09:15:00.000Z",
    "updatedBy": "Xq3vT9mB2kLpR7sN4wYc8dZf1aHj"
  }
}
GET/workspaces/{workspaceId}/memberships

List workspace memberships

Portéememberships:read

Paramètres de chemin

workspaceIdstringobligatoire

ID of the workspace.

Paramètres de requête

limitinteger

Maximum number of items to return, from 1 to 100. A missing, invalid or non-positive value falls back to 20, and a larger value to 100.

Par défaut20

startAfterstring

Cursor of the page to return: the nextCursor of the previous page.

fieldsstring

Comma-separated property paths to include in the response, or in each item of a list. Use dots for nested paths.

idsstring[]

Comma-separated IDs of the items to return, up to 30. When set, limit, startAfter and the filters are ignored.

Renvoie

200

List of items

dataMembership[]obligatoire

Items of the page, in list order.

limitintegerobligatoire

Page size of the request, or the number of requested ids.

nextCursorstring

Cursor of the next page, to pass as startAfter. Absent when the page holds fewer items than limit; a full last page still has one, and the page it points to is empty.

curl 'https://api.business.swayapp.io/v1/workspaces/Wk7fQ2xR9bLm4tZp8sNv/memberships' \
  -H "Authorization: Bearer $SWAY_API_KEY"
{
  "data": [
    {
      "firestoreId": "Xq3vT9mB2kLpR7sN4wYc8dZf1aHj",
      "workspaceId": "Wk7fQ2xR9bLm4tZp8sNv",
      "userId": "Xq3vT9mB2kLpR7sN4wYc8dZf1aHj",
      "displayName": "string",
      "email": "anna.meier@example.com",
      "photoUrl": "https://example.com",
      "role": "ws.owner",
      "activation": {
        "enabled": true,
        "updateDateTime": "2026-03-02T09:15:00.000Z",
        "updatedBy": "Xq3vT9mB2kLpR7sN4wYc8dZf1aHj"
      }
    }
  ],
  "limit": 0,
  "nextCursor": "string"
}
PATCH/workspaces/{workspaceId}/memberships/{membershipId}

Update a workspace membership

Portéememberships:write

Paramètres de chemin

workspaceIdstringobligatoire

ID of the workspace.

membershipIdstringobligatoire

ID of the membership, the same as the user ID of the member.

Paramètres de requête

fieldsstring

Comma-separated property paths to include in the response, or in each item of a list. Use dots for nested paths.

Corps de la requête

rolestringobligatoire

Valeursws.ownerws.adminws.memberws.viewerba.ownerba.adminba.member

Renvoie

200

Successful response

dataMembershipobligatoire
curl -X PATCH 'https://api.business.swayapp.io/v1/workspaces/Wk7fQ2xR9bLm4tZp8sNv/memberships/Xq3vT9mB2kLpR7sN4wYc8dZf1aHj' \
  -H "Authorization: Bearer $SWAY_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "role": "ws.owner"
}'
{
  "data": {
    "firestoreId": "Xq3vT9mB2kLpR7sN4wYc8dZf1aHj",
    "workspaceId": "Wk7fQ2xR9bLm4tZp8sNv",
    "userId": "Xq3vT9mB2kLpR7sN4wYc8dZf1aHj",
    "displayName": "string",
    "email": "anna.meier@example.com",
    "photoUrl": "https://example.com",
    "role": "ws.owner",
    "activation": {
      "enabled": true,
      "updateDateTime": "2026-03-02T09:15:00.000Z",
      "updatedBy": "Xq3vT9mB2kLpR7sN4wYc8dZf1aHj"
    }
  }
}
POST/workspaces/{workspaceId}/memberships/{membershipId}/disable

Disable a workspace membership

Portéememberships:write

Paramètres de chemin

workspaceIdstringobligatoire

ID of the workspace.

membershipIdstringobligatoire

ID of the membership, the same as the user ID of the member.

Paramètres de requête

fieldsstring

Comma-separated property paths to include in the response, or in each item of a list. Use dots for nested paths.

Renvoie

200

Successful response

dataMembershipobligatoire
curl -X POST 'https://api.business.swayapp.io/v1/workspaces/Wk7fQ2xR9bLm4tZp8sNv/memberships/Xq3vT9mB2kLpR7sN4wYc8dZf1aHj/disable' \
  -H "Authorization: Bearer $SWAY_API_KEY"
{
  "data": {
    "firestoreId": "Xq3vT9mB2kLpR7sN4wYc8dZf1aHj",
    "workspaceId": "Wk7fQ2xR9bLm4tZp8sNv",
    "userId": "Xq3vT9mB2kLpR7sN4wYc8dZf1aHj",
    "displayName": "string",
    "email": "anna.meier@example.com",
    "photoUrl": "https://example.com",
    "role": "ws.owner",
    "activation": {
      "enabled": true,
      "updateDateTime": "2026-03-02T09:15:00.000Z",
      "updatedBy": "Xq3vT9mB2kLpR7sN4wYc8dZf1aHj"
    }
  }
}

Construisez sur vos propres données.

Créez un compte, ouvrez Profil › Développeur et créez une clé limitée aux ressources dont vous avez besoin. Une question sur une intégration ? L’équipe y répond lors d’un appel.