Version: 1.0.0

Pages - Invites

Invite is the way to ask if user want to join a page. Concerned user can accept or refuse invitation.


Page Invite

To create a page you have to make a HTTP POST request with parameters in JSON form. There are some required parameters for this operation:

  • target_type string: Type of target for invite, here: Page.
  • target_id string: Relate to the page id.
  • user_id string: User who send invite.
  • user_target_ids array: An array of all user invites
curl -X POST \
https://YOUR_PROJECT_DOMAIN.potion.social/public-api/v1/invites \
-H 'Api-Key: YOUR_API_KEY' \
-H 'Api-Secret: YOUR_API_SECRET' \
-H 'Content-Type: application/json' \
-d '{
"target_type": "Page",
"target_id": "PAGE_ID",
"user_id": "USER_ID",
"user_target_ids": [
"USER_ID"
]
}'

Answer given return an hash with successfull invite create and an array with errors for user_target_ids given

{
success:[{}],
errors: [{"7897f877a6eded28a6166340b191a896c9d67dbf": "User already invite"}]
}

Please note a user cannot send an invite if he have already an waiting invite. Of course if it is already in page, he can't send an invite.

List access invites

You can list all invites by two methods:

  • The first is with a HTTP GET request on invites API point.

    curl -X GET \
    https://YOUR_PROJECT_DOMAIN.potion.social/public-api/v1/invites \
    -H 'Api-Key: YOUR_API_KEY' \
    -H 'Api-Secret: YOUR_API_SECRET' \
    -H 'Content-Type: application/json' \
  • The second is by page endpoint

    curl -X GET \
    https://YOUR_PROJECT_DOMAIN.potion.social/public-api/v1/pages/PAGE_ID/invites \
    -H 'Api-Key: YOUR_API_KEY' \
    -H 'Api-Secret: YOUR_API_SECRET' \
    -H 'Content-Type: application/json' \

You can pass params to filter:

  • user_id string: To have invites sent by user.
  • user_target_id string: To have invites received by user.
  • state string: State of access invite. It can be accepted or waiting or refused
  • target_type string: Type of target for invite, here: Page. Available only on first method
  • target_id string: Relate to the page id. Available only on first method

The response will look like this

{
"items":[
{
"id":"2e8dd42ac25c473e958ec49799e43cf4",
"user": {
"id":"7897f877a6eded28a6166340b191a896c9d67dbf",
"nickname":"JohnDoe",
...
},
user_id: "7897f877a6eded28a6166340b191a896c9d67dbf"
"user_target": {
"id":"ae31828c3e7d4c3482cd4fcf11a0ccc1",
"nickname":"JeanDupont",
...
},
user_target_id: "ae31828c3e7d4c3482cd4fcf11a0ccc1"
target: {
"id":"2e8dd42ac25c473e958ec49799e43cf4",
"name":"My First User",
"slug":"my-first-page",
...
},
target_type: "Page"
target_id:"2e8dd42ac25c473e958ec49799e43cf4"
is_accepted: false,
created_at: "2019-12-27T09:50:58.000+01:00",
updated_at: "2020-01-02T16:18:42.000+01:00"
},
...
],
"total_items":2
}

Accept or refuse an invite

Now you have method to get and create invites, you have to accept or refuse it. When you accept it, the flag is_validate is passed to true. A follow for page is automaticly created.

curl -X PUT \
https://YOUR_PROJECT_DOMAIN.potion.social/public-api/v1/invites/:ID/accept \
-H 'Api-Key: YOUR_API_KEY' \
-H 'Api-Secret: YOUR_API_SECRET' \
-H 'Content-Type: application/json' \

If you refuse it, the flag is_validate is passed to false.

curl -X PUT \
https://YOUR_PROJECT_DOMAIN.potion.social/public-api/v1/invites/:ID/refuse \
-H 'Api-Key: YOUR_API_KEY' \
-H 'Api-Secret: YOUR_API_SECRET' \
-H 'Content-Type: application/json' \

Note: If you check right, only administrator of page can accept or refuse it.

Webhooks

You can configure an url in webhook. You will have a webhook when an invite is created, updated or deleted