← All posts
Tutorial

Get a WhatsApp Group Invite Link via API: Read vs Reset

To retrieve a WhatsApp group invite link through UnifyPort, call GET /v1/accounts/{account_id}/groups/invite-code with group_id as a query parameter. The response contains data.invite_url and data.invite_code. Reading the link is not resetting it. WhatsApp provides a native admin action to deactivate an invite link and create a new one; UnifyPort’s public reference documents retrieval, not a reset operation.

Key takeaways

  • Select the connected account and group together; the invite code is not the group ID.
  • Fetch the link on your backend and expose it only to authorized operators.
  • Treat link retrieval, link sharing, join approval, and link reset as separate actions.
  • After a native reset, retrieve the current link again and replace the copies your application controls.

WhatsApp’s official group invitation guide describes inviting people by link and warns that recipients can forward that link. It also describes admins deactivating a group invite link and creating a new one. Do not confuse that app operation with an API read.

The UnifyPort invite-link reference defines this narrower contract:

Input or outputMeaning
account_id in the pathConnected messaging account used for the operation
group_id in the queryProvider group identifier
data.invite_urlReturned invitation URL
data.invite_codeReturned invitation code, not a conversation ID

The current action support matrix maps this operation to whatsapp, not LINE, Telegram, Zalo, or the separate whatsapp-protocol provider. The endpoint reference warns that group-admin permission is required for most providers. For this workflow, use an authorized WhatsApp group-admin account and verify its current permissions rather than assuming that workspace API access grants group authority.

This is an unofficial interface for a connected account, not a WhatsApp Cloud API endpoint.

First select the group under the intended account using List groups. That endpoint includes joined groups even when they have not been used for messaging. Follow its pagination and retain the selected item’s id; for a group, its conversation_id equals its id. Do not locate a group solely by a display name that another group could share.

The following request is illustrative, not an executed test. Set the environment variables to your backend-held API key, selected account ID, and returned group ID:

curl --get \
  "https://api.unifyport.ai/v1/accounts/${UNIFYPORT_ACCOUNT_ID}/groups/invite-code" \
  -H "X-Api-Key: ${UNIFYPORT_API_KEY}" \
  --data-urlencode "group_id=${WHATSAPP_GROUP_ID}"

Query encoding matters because provider identifiers can contain characters such as @. Keep the API key on the server; do not put this authenticated call in browser JavaScript.

On a successful response, read data.invite_url and data.invite_code. Do not construct a guessed invitation URL from the group ID. If the response is unsuccessful or lacks the expected link, leave the UI in an error or unavailable state instead of showing a fabricated value.

For diagnostics, record the HTTP status, error code, and server request_id. The request-tracing guide explains how to retain that evidence without logging entire response bodies. In this flow, the body contains an invitation link that should not enter analytics or general application logs.

Design separate controls for separate intentions

A useful operator interface can make these boundaries explicit:

ControlIntended behaviorNot implied
Show current linkRead and display the current API resultA new link was created
Copy linkCopy the displayed URL for an authorized recipientThe person has joined
Review join requestsOpen the moderation workflowA link was reset
Reset linkDirect an admin to the native WhatsApp actionA documented UnifyPort reset call exists

Require application-level permission before revealing or copying a link. Avoid placing it in public dashboards, support screenshots, or analytics properties. If your UI caches the result, label it as a previously retrieved value rather than promising it is still current.

Join approval belongs to a different workflow. If you need moderation, use the WhatsApp join-request approval queue, which reconciles pending requests before making decisions. Fetching an invitation link neither enables approval nor approves a requester.

Update stored copies after a native reset

Consider a hypothetical situation: an admin believes an invitation has been shared too widely and resets it in WhatsApp. Your application may still hold the earlier URL.

Recommended application procedure:

  1. Stop distributing the cached link while the admin completes the native action.
  2. Read the invite-link endpoint again for the same account and group.
  3. Show the freshly retrieved result to the authorized operator for verification.
  4. Replace application-owned links and any QR images generated from the old URL.
  5. Notify owners of other distribution surfaces that their copies need review.

These are operational recommendations, not an atomic rotation feature. The public reference does not document a reset parameter, a reset endpoint, a link-expiration timestamp, or a dedicated reset-confirmation webhook. Do not add guessed fields or interpret the absence of an event as proof that nothing changed. If the new read fails, keep distribution paused or explicitly unresolved rather than silently restoring the old cached value.

FAQ

The documented operation retrieves a link and code. It does not promise rotation or generation of a fresh link on every read.

Can I use invite_code as group_id?

No. Use the provider group ID selected under the connected account. The invitation code is a separate returned value.

No reset operation is documented in the current public reference. Use WhatsApp’s native admin control, then retrieve the current link again.

Does a failed read mean the group was deleted?

No. Check the HTTP status and error details. get_group_invite_code_failed describes a server-side or upstream retrieval failure; it is not evidence of deletion.

Next step and sources

Implement the read-only flow from Get group invite link first. Before release, test group selection, permission failure, query encoding, redacted logs, and refreshing an application-owned copy after an authorized native reset. These are proposed checks, not reported test results.

References checked on 2026-10-15:

UnifyPort API

Turn messaging integration into a stable product pipeline.

Start by sending through one API, then bring every inbound message back into your business system with standard events.