Join communities and run the ones you manage

Join and leave communities, accept invites, and for communities you run change the settings, invite members and answer join requests with the API.

View as Markdown

Creating a community is its own guide. This one is everything after.

Scopes: network for membership, edit for settings ยท Quotas: joining and inviting use connect (one unit per person invited); settings use edit

Membership

WhatEndpoint
Join a public community, or ask to join one that asksPOST /api/v1/communities/{slug}/join
Leave, cancel your request, or turn down an invitePOST /api/v1/communities/{slug}/leave
Accept an invitePOST /api/v1/communities/{slug}/invite/accept
Decline an invitePOST /api/v1/communities/{slug}/invite/decline

A private community is by invite only. The answer's membership says where you stand. The creator cannot leave their own community.

Communities you run

Admins and the creator can:

WhatEndpoint
Read the settingsGET /api/v1/communities/{slug}/settings
Change the settingsPUT /api/v1/communities/{slug}
Invite up to 10 membersPOST /api/v1/communities/{slug}/invites with {"usernames": [...]}
Accept or decline a request to joinPOST /api/v1/communities/{slug}/requests/accept or /decline with {"username": "..."}

A settings change sends only what changes; the name, description, icon, banner and visibility you do not send are kept. An icon_url or banner_url that links to an image elsewhere is imported. Changing roles and removing members stay on the website.

cURL
curl -X PUT "https://urnextdoor.com/api/v1/communities/rooftop-growers" \
  -H "Authorization: Bearer $UND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "description": "<p>Gardens on roofs across Pune.</p>"
}'
JavaScript
const res = await fetch("https://urnextdoor.com/api/v1/communities/rooftop-growers", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.UND_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    description: "<p>Gardens on roofs across Pune.</p>",
  }),
});
console.log(res.status, await res.json());
Python
import os

import requests

api_key = os.environ["UND_API_KEY"]

response = requests.put(
    "https://urnextdoor.com/api/v1/communities/rooftop-growers",
    headers={
        "Authorization": f"Bearer {api_key}",
    },
    json={
        "description": "<p>Gardens on roofs across Pune.</p>",
    },
    timeout=30,
)
print(response.status_code, response.json())
PHP
<?php
$apiKey = getenv('UND_API_KEY');

$payload = [
    'description' => '<p>Gardens on roofs across Pune.</p>',
];

$ch = curl_init('https://urnextdoor.com/api/v1/communities/rooftop-growers');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode($payload),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);

echo $status, PHP_EOL, $body, PHP_EOL;

Next steps

Last updated