> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel an invitation

> Take back an invitation not accepted yet.

> [!NOTE]
>
> Needs `team:delete`, and a role in the workspace that can remove teammates: owners and admins can. See [Permissions](/docs/essentials/authentication.md#permissions).

`{id}` is the invitation's `invitation_id` from [the team list](/docs/api-reference/team/list.md), and `workspace_id` names the workspace. The invitation's link stops working at once, and it emails no one.

The address can be [invited](/docs/api-reference/team/invite.md) again, but one invitation goes to an address for each workspace a day: cancelling and inviting again the same day answers `429`.

Every plan, Free included.

## Errors

| Status | `error` | When | Retry? |
| - | - | - | - |
| 401 | | No API key, or not a valid one. | No: fix the key. |
| 403 | | The key lacks `team:delete`, or its user is inactive. | No: grant it in Settings → API. |
| 403 | | Your role in the workspace can't remove teammates. | No. |
| 403 | `team_read_only` | You're a member, not the owner, of a team that is read-only: the owner's plan stopped including one 7 days ago or more ([Team read-only](/docs/essentials/error-handling.md#team-read-only)). The invitation still stands. | After the owner upgrades. |
| 404 | | No invitation still open with that id in the workspace: it was accepted, declined or cancelled. | No. |
| 422 | | No `workspace_id`, or one the key can't reach. | No: fix the request. |
| 429 | | More than 60 requests a minute. | Yes, after `Retry-After` seconds. |

## Related

* [List team members](/docs/api-reference/team/list.md): the team left.
* [Invite a team member](/docs/api-reference/team/invite.md): invite them again.


## OpenAPI

````yaml DELETE /team-members/invitations/{id}
openapi: 3.0.3
info:
  title: PostSyncer API
  description: >-
    Post to 14 social networks from your code: posts, media, comments,
    analytics, webhooks and more.
  version: 1.0.0
servers:
  - url: https://postsyncer.com/api/v1
security:
  - bearerAuth: []
tags:
  - name: Workspaces
    description: The workspaces the key can reach.
  - name: Accounts
    description: Connected social accounts, links to connect more, and disconnecting them.
  - name: Posts
    description: Drafts, scheduled and published posts, approvals and a post's history.
  - name: Post settings
    description: A post's auto-plug, comment moderation and contact collection.
  - name: Media
    description: >-
      The media library: file uploads, URL imports, and reading videos and
      social posts' files.
  - name: Folders
    description: Folders that organise the media library.
  - name: Comments
    description: >-
      Comments on your posts: reading, replying, editing, hiding, deleting and
      syncing them.
  - name: Reviews
    description: Google Business Profile reviews and your replies to them.
  - name: Analytics
    description: Workspace, account and post performance.
  - name: Brand
    description: >-
      A workspace's brand: identity, voice, look, accounts, competitors,
      learnings and rules.
  - name: Labels
    description: Labels used to tag posts.
  - name: Campaigns
    description: Campaigns used to group posts.
  - name: Snippets
    description: Saved snippets and hashtag groups to drop into posts.
  - name: Webhooks
    description: Signed webhook endpoints that get your notification events.
  - name: Billing
    description: >-
      The owner's plan, invoices and the links that pay for, change or cancel
      it.
  - name: Team
    description: A workspace's teammates and invitations, and their roles.
  - name: Notifications
    description: >-
      Your bell and notification settings, and the workspace's Slack, Discord
      and Telegram channels.
  - name: Blog-to-social
    description: Blog feeds that turn a workspace's new articles into posts.
  - name: Products
    description: Products the workspace's posts can promote.
  - name: Contacts
    description: People who commented on the workspace's posts, and the lists they are on.
  - name: Profile
    description: 'The key''s user: their name and sign-in email.'
  - name: API keys
    description: 'Your API keys: listing and deleting them.'
  - name: Agent sign-up
    description: >-
      An AI agent signs a person up with a code emailed to them, and gets their
      first key. No key needed.
paths:
  /team-members/invitations/{id}:
    delete:
      tags:
        - Team
      summary: Cancel an invitation
      description: >-
        Needs `team:delete`. Your role in the workspace must also let you remove
        teammates: owners and admins can. Cancels an invitation not accepted
        yet: its link stops working at once, and it emails no one. The address
        can be invited again; one invitation goes to an address for each
        workspace a day, so cancelling and inviting again the same day answers
        `429`. Every plan, Free included.
      operationId: cancelTeamInvitation
      parameters:
        - name: id
          in: path
          required: true
          description: 'The invitation''s id: `invitation_id` in the team list.'
          schema:
            type: integer
            example: 7
        - name: workspace_id
          in: query
          required: true
          description: The workspace. It must be one the key can reach.
          schema:
            type: integer
            example: 12
      responses:
        '200':
          description: The invitation is cancelled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                default:
                  summary: Cancelled
                  value:
                    message: Invitation cancelled.
        '401':
          $ref: '#/components/responses/Unauthorized401'
        '403':
          description: >-
            The key lacks `team:delete`, its user is inactive, your role in the
            workspace can't remove teammates, or you're a member, not the owner,
            of a read-only team (`team_read_only`: the owner's plan stopped
            including one 7 days ago or more).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                team_read_only:
                  summary: A member of a read-only team
                  value:
                    message: >-
                      Mira Okafor's plan doesn't include a team, so you can only
                      view posts and write team notes in Halden Coffee. Ask them
                      to upgrade.
                    error: team_read_only
                missing_permission:
                  summary: The key lacks team:delete
                  value:
                    message: >-
                      This API key does not have the "team:delete" permission.
                      Edit the key in PostSyncer under Settings → API to grant
                      it.
                role:
                  summary: The role can't delete team members
                  value:
                    message: >-
                      Your role in the workspace "Halden Coffee" does not allow
                      you to delete team members. Ask the workspace owner or an
                      admin to do it, or to change your role.
                inactive_account:
                  summary: The key's user is inactive
                  value:
                    message: Your account is inactive.
        '404':
          description: >-
            No invitation still open with that id in the workspace: never sent,
            or already accepted, declined or cancelled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                not_found:
                  summary: No open invitation
                  value:
                    message: Invitation not found.
        '422':
          description: No `workspace_id`, or one the key can't reach.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
              examples:
                workspace_id:
                  summary: Not a workspace the key can reach
                  value:
                    message: Invalid workspace ID.
                    errors:
                      workspace_id:
                        - Invalid workspace ID.
                workspace_id_missing:
                  summary: No workspace_id
                  value:
                    message: The workspace id field is required.
                    errors:
                      workspace_id:
                        - The workspace id field is required.
        '429':
          $ref: '#/components/responses/RateLimited429'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl --request DELETE \
              --url 'https://postsyncer.com/api/v1/team-members/invitations/7?workspace_id=12' \
              --header 'Authorization: Bearer <token>'
        - lang: javascript
          label: JavaScript
          source: >-
            const options = {method: 'DELETE', headers: {Authorization: 'Bearer
            <token>'}};


            fetch('https://postsyncer.com/api/v1/team-members/invitations/7?workspace_id=12',
            options)
              .then(res => res.json())
              .then(res => console.log(res))
              .catch(err => console.error(err));
        - lang: python
          label: Python
          source: >-
            import requests


            url =
            "https://postsyncer.com/api/v1/team-members/invitations/7?workspace_id=12"


            headers = {"Authorization": "Bearer <token>"}


            response = requests.delete(url, headers=headers)


            print(response.text)
        - lang: php
          label: PHP
          source: |-
            <?php

            $curl = curl_init();

            curl_setopt_array($curl, [
              CURLOPT_URL => "https://postsyncer.com/api/v1/team-members/invitations/7?workspace_id=12",
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_ENCODING => "",
              CURLOPT_MAXREDIRS => 10,
              CURLOPT_TIMEOUT => 30,
              CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
              CURLOPT_CUSTOMREQUEST => "DELETE",
              CURLOPT_HTTPHEADER => [
                "Authorization: Bearer <token>"
              ],
            ]);

            $response = curl_exec($curl);
            $err = curl_error($curl);

            curl_close($curl);

            if ($err) {
              echo "cURL Error #:" . $err;
            } else {
              echo $response;
            }
components:
  schemas:
    Error:
      type: object
      description: >-
        An error answer. Every one has `message`, in plain words; some add an
        `error` code and fields of their own.
      required:
        - message
      properties:
        message:
          type: string
          description: What went wrong and what to do about it.
        error:
          type: string
          description: >-
            A code a few errors add, such as `rate_limited`. See [Handle
            errors](/essentials/error-handling#answers-with-an-error-code).
    ValidationError:
      type: object
      description: '422: the request didn''t pass validation, and nothing changed.'
      required:
        - message
        - errors
      properties:
        message:
          type: string
          description: >-
            The first error and, when there are more, how many: `(and 1 more
            error)`, `(and 2 more errors)`.
        errors:
          type: object
          description: >-
            The messages, by field. A field inside a list is named with dots:
            `accounts.0.id`.
          additionalProperties:
            type: array
            items:
              type: string
  responses:
    Unauthorized401:
      description: No API key, or not a valid one.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            unauthenticated:
              summary: No valid API key
              value:
                message: Unauthenticated.
    RateLimited429:
      description: >-
        More than 60 requests in a minute from this key's user (the API and the
        MCP server share the count). Wait `Retry-After` seconds.
      headers:
        Retry-After:
          description: Seconds until requests are allowed again.
          schema:
            type: integer
        X-RateLimit-Limit:
          description: Requests allowed a minute.
          schema:
            type: integer
        X-RateLimit-Remaining:
          description: Requests left this minute.
          schema:
            type: integer
        X-RateLimit-Reset:
          description: When requests are allowed again, as a Unix timestamp.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            too_many_attempts:
              summary: Too many requests
              value:
                message: Too Many Attempts.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.