Skip to main content

Try the live demo!

Search

Block or Unblock Contact

Requires the `contacts:block` permission.

PUT /api/v1/contacts/{id}/block

Requires the contacts:block permission.

Authentication

Use an agent API key and secret.

Parameters

All parameters are path parameters. All parameters are required.

Name Type
id string

Request body

Update the contact's block status.

Required: Yes.

application/json

All fields are required.

Field Type Description
enabled boolean Set to false to block, true to unblock example: false

Responses

200

Contact block status updated successfully

Content type: application/json.

Field Type Required Description
status string No example: "success"
data object No
data.id integer No
data.created_at string (date-time) No
data.updated_at string (date-time) No
data.first_name string No
data.last_name string No
data.email string (email) No nullable: true
data.type string No
data.availability_status string (enum) No enum: ["online", "away", "away_manual", "offline", "away_and_reassigning"] example: "online"
data.avatar_url string No nullable: true
data.phone_number string No nullable: true
data.phone_number_country_code string No nullable: true
data.custom_attributes object No nullable: true
data.enabled boolean No
data.last_active_at string (date-time) No nullable: true
data.last_login_at string (date-time) No nullable: true
data.roles array of string No nullable: true
data.roles[] string
data.permissions array of string No nullable: true
data.permissions[] string
data.teams array of object No nullable: true
data.teams[].id integer No example: 1
data.teams[].name string No example: "Support Team"
data.teams[].emoji string No nullable: true example: "🛠️"
data.api_key string No nullable: true
data.api_key_last_used_at string (date-time) No nullable: true
data.country string No ISO 3166-1 alpha-2 country code nullable: true example: "US"
data.meta object No nullable: true
data.external_user_id string No External identifier for the user in your own system nullable: true
data.contact_channel_id integer No Present only when non-zero

400

Invalid request

Content type: application/json.

All fields are optional.

Field Type Description
status string example: "error"
message string Error message example: "Invalid request"
data unspecified Additional error data nullable: true
error_type string (enum) enum: ["GeneralException", "PermissionException", "InputException", "DataException", "NetworkException", "NotFoundException", "ConflictException", "UnauthorizedException", "RateLimitException"]

401

Unauthorized

Content type: application/json.

Response fields match the 400 response.

403

Forbidden

Content type: application/json.

Response fields match the 400 response.

404

Not found

Content type: application/json.

Response fields match the 400 response.

500

Internal server error

Content type: application/json.

Response fields match the 400 response.

Specification

Download the complete OpenAPI specification.

OpenAPI definition for this endpoint
openapi: 3.0.0
info:
  title: libredesk API
  description: >-
    REST API documentation for libredesk helpdesk system.


    ## Authentication


    The libredesk API supports two authentication methods:


    ### 1. Basic Authentication

    Use your API key and secret with Basic authentication:

    ```

    Authorization: Basic <base64_encoded_api_key:api_secret>

    ```


    ### 2. Token Authentication  

    Use your API key and secret with token authentication:

    ```

    Authorization: token api_key:api_secret

    ```


    To obtain API credentials, generate them from your agent profile in the
    libredesk dashboard.
  version: 1.0.0
servers:
  - url: http://localhost:8080
    description: Local development server
security:
  - basicAuth: []
  - tokenAuth: []
paths:
  /api/v1/contacts/{id}/block:
    put:
      tags:
        - Contacts
      summary: Block or Unblock Contact
      description: Requires the `contacts:block` permission.
      operationId: handleBlockContact
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        description: Update the contact's block status.
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                enabled:
                  type: boolean
                  description: Set to `false` to block, `true` to unblock
                  example: false
              required:
                - enabled
      responses:
        '200':
          description: Contact block status updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - basicAuth: []
        - tokenAuth: []
components:
  schemas:
    ContactResponse:
      type: object
      properties:
        status:
          type: string
          example: success
        data:
          $ref: '#/components/schemas/Contact'
    ErrorResponse:
      type: object
      description: Error response format
      properties:
        status:
          type: string
          example: error
        message:
          type: string
          description: Error message
          example: Invalid request
        data:
          nullable: true
          description: Additional error data
        error_type:
          type: string
          enum:
            - GeneralException
            - PermissionException
            - InputException
            - DataException
            - NetworkException
            - NotFoundException
            - ConflictException
            - UnauthorizedException
            - RateLimitException
    Contact:
      type: object
      properties:
        id:
          type: integer
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        first_name:
          type: string
        last_name:
          type: string
        email:
          type: string
          format: email
          nullable: true
        type:
          type: string
        availability_status:
          type: string
          enum:
            - online
            - away
            - away_manual
            - offline
            - away_and_reassigning
          example: online
        avatar_url:
          type: string
          nullable: true
        phone_number:
          type: string
          nullable: true
        phone_number_country_code:
          type: string
          nullable: true
        custom_attributes:
          type: object
          nullable: true
        enabled:
          type: boolean
        last_active_at:
          type: string
          format: date-time
          nullable: true
        last_login_at:
          type: string
          format: date-time
          nullable: true
        roles:
          type: array
          items:
            type: string
          nullable: true
        permissions:
          type: array
          items:
            type: string
          nullable: true
        teams:
          type: array
          nullable: true
          items:
            $ref: '#/components/schemas/TeamCompact'
        api_key:
          type: string
          nullable: true
        api_key_last_used_at:
          type: string
          format: date-time
          nullable: true
        country:
          type: string
          nullable: true
          description: ISO 3166-1 alpha-2 country code
          example: US
        meta:
          type: object
          nullable: true
        external_user_id:
          type: string
          nullable: true
          description: External identifier for the user in your own system
        contact_channel_id:
          type: integer
          description: Present only when non-zero
    TeamCompact:
      type: object
      properties:
        id:
          type: integer
          example: 1
        name:
          type: string
          example: Support Team
        emoji:
          type: string
          nullable: true
          example: 🛠️
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: >-
        Basic authentication using base64 encoded API key and secret. Format:
        `Authorization: Basic <base64(api_key:api_secret)>`
    tokenAuth:
      type: apiKey
      name: Authorization
      in: header
      description: >-
        Token authentication using API key and secret. Format: `Authorization:
        token api_key:api_secret`

Was this article helpful?