Message Lifecycle

Create a Message

Create a Message in the specified Channel.

Send a JSON document that matches the Message schema with an HTTP header of Content-Type: application/json. Currently, the only keys we use from your JSON will be text, reply_to, annotations, entities, and machine_only.

If you would like to specify your own entities, please refer to the user specified entites documentation, otherwise we will parse out links, hashtags, and mentions from the text field.

If you want to test how your text will be processed you can use the text processor.

Creating Private Messages for use with net.app.core.pm Channels

To create private group messages for use in net.app.core.pm channels, you can specify the special channel_id of pm. With this parameter, the server will look for an extra field in the provided message object called destinations which is a list of user ids to send this message to. If a private message channel already exists between this group of users, its channel_id will be reused. Otherwise, a new channel will be created and the users specified in the destinations list will be auto-subscribed (according to their subscription preferences) and able to write to that channel. Note that the destinations value may include user ids in the form of “@username” or integer id.

This endpoint responds to general Message parameters.

Endpoint

Method URL Token
POST https://api.app.net/channels/{channel_id}/messages User

URL Parameters

Name Description
channel_id The id of the Channel in which to create the Message. Alternatively, you can specify pm to auto-create/reuse a net.app.core.pm private message channel.

Generic Channel Example

to see more complete examples.

curl -X POST -H "Authorization: Bearer <YOUR ACCESS TOKEN>" -H "X-ADN-Pretty-JSON: 1" \
    -H "Content-Type: application/json" -d "{
  \"text\": \"Hello channel!\"
}" \
    "https://api.app.net/channels/1/messages"
{
  "data": {
    "channel_id": "1",
    "created_at": "2012-12-11T00:31:49Z",
    "entities": {
      "hashtags": [

      ],
      "links": [

      ],
      "mentions": [

      ]
    },
    "html": "<span itemscope=\"https://app.net/schemas/Post\">Hello channel!</span>",
    "id": "1",
    "machine_only": false,
    "num_replies": 0,
    "source": {
      "client_id": "UxUWrSdVLyCaShN62xZR5tknGvAxK93P",
      "link": "https://app.net",
      "name": "Test app"
    },
    "text": "Hello channel!",
    "thread_id": "1",
    "user": "...user object..."
  },
  "meta": {
    "code": 200
  }
}

PM Channel Example

to see more complete examples.

curl -X POST -H "Authorization: Bearer <YOUR ACCESS TOKEN>" -H "X-ADN-Pretty-JSON: 1" \
    -H "Content-Type: application/json" -d "{
  \"text\": \"Hello channel!\",
  \"destinations\": [
    \"@berg\",
    1
  ]
}" \
    "https://api.app.net/channels/pm/messages"
{
  "data": {
    "channel_id": "2",
    "created_at": "2012-12-11T00:31:49Z",
    "entities": {
      "hashtags": [

      ],
      "links": [

      ],
      "mentions": [

      ]
    },
    "html": "<span itemscope=\"https://app.net/schemas/Post\">Hello channel!</span>",
    "id": "105",
    "machine_only": false,
    "num_replies": 0,
    "source": {
      "client_id": "UxUWrSdVLyCaShN62xZR5tknGvAxK93P",
      "link": "https://app.net",
      "name": "Test app"
    },
    "text": "Hello channel!",
    "thread_id": "105",
    "user": "...user object..."
  },
  "meta": {
    "code": 200
  }
}

Delete a Message

Delete a message. The current user must be the same user who created the Message. It returns the deleted Message on success.

You can always delete a message you created even if you are no longer able to view the rest of the Channel anymore.

Remember, access tokens can not be passed in a HTTP body for DELETE requests. Please refer to the authentication documentation.

This endpoint responds to general Message parameters.

Endpoint

Method URL Token Scope
DELETE https://api.app.net/channels/{channel_id}/messages/{message_id} User public_messages or messages

URL Parameters

Name Description
channel_id The id of the Channel this Message belongs to.
message_id The id of the Message to delete.

Example

to see more complete examples.

curl -X DELETE -H "Authorization: Bearer <YOUR ACCESS TOKEN>" -H "X-ADN-Pretty-JSON: 1" \
    "https://api.app.net/channels/1/messages/1"
{
  "data": {
    "channel_id": "1",
    "created_at": "2012-12-11T00:31:49Z",
    "entities": {
      "hashtags": [

      ],
      "links": [

      ],
      "mentions": [

      ]
    },
    "id": "1",
    "machine_only": false,
    "num_replies": 0,
    "source": {
      "client_id": "UxUWrSdVLyCaShN62xZR5tknGvAxK93P",
      "link": "https://app.net",
      "name": "Test app"
    },
    "thread_id": "1",
    "user": "...user object...",
    "is_deleted": true
  },
  "meta": {
    "code": 200
  }
}

Retrieve the Messages in a Channel

Retrieve a stream of the Messages in a channel.

This endpoint responds to general Message parameters.

Responses from this endpoint are paginated.

Endpoint

Method URL Token Scope
GET https://api.app.net/channels/{channel_id}/messages User public_messages or messages

URL Parameters

Name Description
channel_id The id of the Channel to retrieve Messages from.

Example

to see more complete examples.

curl -H "Authorization: Bearer <YOUR ACCESS TOKEN>" -H "X-ADN-Pretty-JSON: 1" \
    "https://api.app.net/channels/1/messages"
{
  "data": [
    {
      "channel_id": "1",
      "created_at": "2012-12-11T00:31:49Z",
      "entities": {
        "hashtags": [

        ],
        "links": [

        ],
        "mentions": [

        ]
      },
      "html": "<span itemscope=\"https://app.net/schemas/Post\">Hello channel!</span>",
      "id": "1",
      "machine_only": false,
      "num_replies": 0,
      "source": {
        "client_id": "UxUWrSdVLyCaShN62xZR5tknGvAxK93P",
        "link": "https://app.net",
        "name": "Test app"
      },
      "text": "Hello channel!",
      "thread_id": "1",
      "user": "...user object...",
      "pagination_id": "1"
    }
  ],
  "meta": {
    "code": 200,
    "more": false,
    "marker": {
      "name": "channel:1"
    },
    "min_id": "1",
    "max_id": "1"
  }
}