Servers

As the name suggests, contacts are a core part of Protocol — the very reason Protocol exists is so you can have secure conversations with your contacts. On this page, we'll dive into the different contact endpoints you can use to manage contacts programmatically. We'll look at how to query, create, update, and delete contacts.

The Server model

The contact model contains all the information about your contacts, such as their username, avatar, and phone number. It also contains a reference to the conversation between you and the contact and information about when they were last active on Protocol.

Properties

  • Name
    id
    Type
    string
    Description

    Unique identifier for the server.

  • Name
    name
    Type
    string
    Description

    The friendly-name of server.

  • Name
    vendor
    Type
    enum
    Description

    Vendor of RDBMS: PGSQL, MYSQL, MSSQL, ORACLE

  • Name
    host
    Type
    string
    Description

    Address IP or domain-name of server machine.

  • Name
    port
    Type
    integer
    Description

    TCP/IP port of server.

  • Name
    userName
    Type
    string
    Description

    The user name of database administrator.

  • Name
    password
    Type
    string
    Description

    The user password of database administrator.

  • Name
    createdAt
    Type
    timestamp (RFC 3339 / ISO 8601)
    Description

    Date of creation record of this server in application's database.

  • Name
    updatedAt
    Type
    timestamp (RFC 3339 / ISO 8601)
    Description

    Date of last modification record of this server in application's database.

  • Name
    accesses
    Type
    ServerAccess[]
    Description

    List of accesses to this server.

    • Name
      serverId
      Type
      string
      Description

      Unique identifier for the server.

    • Name
      groupId
      Type
      string
      Description

      Unique identifier for the group of users.

    • Name
      userId
      Type
      string
      Description

      Unique identifier for the user.

    • Name
      privileges
      Type
      ServerPrivileges
      Description
        • Name
          createDatabase
          Type
          boolean
          Description

          Can creates new databases on this server.

        • Name
          dropDatabase
          Type
          boolean
          Description

          Can drops any databases on this server.

    • Name
      createdAt
      Type
      timestamp (RFC 3339 / ISO 8601)
      Description

      Date of creation record of this server in application's database.

    • Name
      updatedAt
      Type
      timestamp (RFC 3339 / ISO 8601)
      Description

      Date of last modification record of this server in application's database.

  • Name
    stats
    Type
    ServerStats
    Description

    Statistics of this server.

      • Name
        databasesNumber
        Type
        integer
        Description

        Number of databases in this server.

      • Name
        databasesSize
        Type
        integer
        Description

        Size of all databases in this server (in bytes).

      • Name
        freeSpace
        Type
        integer
        Description

        Available free space on this server (in bytes).

      • Name
        updatedAt
        Type
        timestamp (RFC 3339 / ISO 8601)
        Description

        Date of last modification of this statistics.


GET/v1/servers

List all servers

This endpoint allows you to retrieve a paginated list of all your servers. By default, a maximum of ten servers are shown per page.

Optional attributes

  • Name
    page
    Type
    integer
    Description

    Number of page (starting from: 1, default: 1)

  • Name
    limit
    Type
    integer
    Description

    Size of page (default: 10)

Request

GET
/v1/servers
curl -G https://anonymate/v1/servers \
-H "Authorization: Bearer {token}"

Response

{
    "status": "OK",
    "data": [
{
    "id": "WAz8eIbvDR60rouK",
    "username": "FrankMcCallister",
    "phone_number": "1-800-759-3000",
    "avatar_url": "https://assets.protocol.chat/avatars/frank.jpg",
    "display_name": null,
    "conversation_id": "xgQQXg3hrtjh7AvZ",
    "last_active_at": 705103200,
    "created_at": 692233200
},
{
    "id": "hSIhXBhNe8X1d8Et"
    // ...
}
    ]
}

POST/v1/servers

Add a server

This endpoint allows you to add a new server to your Anonymate instance.

Required attributes

  • Name
    name
    Type
    string
    Description

    The username for the contact.

  • Name
    vendor
    Type
    enum
    Description

    The phone number for the contact.

  • Name
    host
    Type
    string
    Description

    The phone number for the contact.

  • Name
    port
    Type
    integer
    Description

    The phone number for the contact.

  • Name
    userName
    Type
    string
    Description

    The phone number for the contact.

  • Name
    password
    Type
    string
    Description

    The phone number for the contact.

Request

POST
/v1/servers
curl https://anonymate/v1/servers \
-H "Authorization: Bearer {token}" \
-d username="FrankMcCallister" \
-d phone_number="1-800-759-3000" \
-d avatar_url="https://assets.protocol.chat/avatars/frank.jpg"

Response

{
    "id": "WAz8eIbvDR60rouK",
    "username": "FrankMcCallister",
    "phone_number": "1-800-759-3000",
    "avatar_url": "https://assets.protocol.chat/avatars/frank.jpg",
    "display_name": null,
    "conversation_id": "xgQQXg3hrtjh7AvZ",
    "last_active_at": null,
    "created_at": 692233200
}

GET/v1/servers/:id

Retrieve a server

This endpoint allows you to retrieve a contact by providing their Protocol id. Refer to the list at the top of this page to see which properties are included with contact objects.

Request

GET
/v1/servers/WAz8eIbvDR60rouK
curl https://api.protocol.chat/v1/contacts/WAz8eIbvDR60rouK \
-H "Authorization: Bearer {token}"

Response

{
    "id": "WAz8eIbvDR60rouK",
    "username": "FrankMcCallister",
    "phone_number": "1-800-759-3000",
    "avatar_url": "https://assets.protocol.chat/avatars/frank.jpg",
    "display_name": null,
    "conversation_id": "xgQQXg3hrtjh7AvZ",
    "last_active_at": 705103200,
    "created_at": 692233200
}

PUT/v1/servers/:id

Update a server

This endpoint allows you to perform an update on a contact. Currently, the only attribute that can be updated on contacts is the display_name attribute which controls how a contact appears in your contact list in Protocol.

Optional attributes

  • Name
    display_name
    Type
    string
    Description

    The contact display name in the contact list. By default, this is just the username.

Request

PUT
/v1/servers/WAz8eIbvDR60rouK
curl -X PUT http://anonymate/v1/servers/WAz8eIbvDR60rouK \
-H "Authorization: Bearer {token}" \
-d display_name="UncleFrank"

Response

{
    "id": "WAz8eIbvDR60rouK",
    "username": "FrankMcCallister",
    "phone_number": "1-800-759-3000",
    "avatar_url": "https://assets.protocol.chat/avatars/frank.jpg",
    "display_name": "UncleFrank",
    "conversation_id": "xgQQXg3hrtjh7AvZ",
    "last_active_at": 705103200,
    "created_at": 692233200
}

DELETE/v1/servers/:id

Delete a server

This endpoint allows you to delete contacts from your contact list in Protocol. Note: This will also delete your conversation with the given contact.

Request

DELETE
/v1/contacts/WAz8eIbvDR60rouK
curl -X DELETE https://api.protocol.chat/v1/contacts/WAz8eIbvDR60rouK \
-H "Authorization: Bearer {token}"

Was this page helpful?