> ## Documentation Index
> Fetch the complete documentation index at: https://learn.social.plus/llms.txt
> Use this file to discover all available pages before exploring further.

# Follow/Unfollow User

> Follow or unfollow another user with the social.plus SDKs.

Use the follow API to create a relationship from the current user to another user. The SDK returns the resulting follow status where the platform exposes one. Depending on network configuration, the status can become `accepted` immediately or remain `pending` until the target user accepts the request.

Use the unfollow API to cancel a pending request or remove an accepted follow relationship.

<Info>
  If the relationship is blocked, follow and unfollow calls can fail or return a blocked status. Read the connection status before rendering a follow button when the UI needs to distinguish blocked users.
</Info>

## Parameters

| Operation     | Parameter                 | Required | Description                                                                                    |
| ------------- | ------------------------- | -------- | ---------------------------------------------------------------------------------------------- |
| Follow user   | `userId` / `targetUserId` | Yes      | ID of the user the current user wants to follow.                                               |
| Unfollow user | `userId` / `targetUserId` | Yes      | ID of the user the current user wants to unfollow or whose pending request should be canceled. |

## Follow User

Follow a user when the current user starts a relationship that may become accepted immediately or remain pending.

<CodeGroup>
  ```swift iOS theme={null}
  let relationship = AmityUserRelationship()
  let response = try await relationship.follow(withUserId: "target-user-id")
  _ = response
  ```

  ```kotlin Android theme={null}
  val disposable = AmityCoreClient.newUserRepository()
      .relationship()
      .follow(userId = targetUserId)
      .subscribe(
          { status: AmityFollowStatus ->
              showSuccessMessage(status.apiKey)
          },
          { error ->
              handleGeneralError(error)
          },
      )
  ```

  ```typescript TypeScript theme={null}
  import { UserRepository } from '@amityco/ts-sdk';

  const { data: followStatus } = await UserRepository.Relationship.follow(userId);

  if (followStatus.status === 'accepted') {
    showSuccessMessage('Following');
  }
  ```

  ```dart Flutter theme={null}
  final status = await AmityCoreClient.newUserRepository()
      .relationship()
      .follow(targetUserId);

  final statusValue = status.value;
  ```
</CodeGroup>

## Unfollow User

Unfollow a user to remove an accepted relationship or cancel a pending follow request.

<CodeGroup>
  ```swift iOS theme={null}
  let relationship = AmityUserRelationship()
  let response = try await relationship.unfollow(withUserId: "target-user-id")
  _ = response
  ```

  ```kotlin Android theme={null}
  val disposable = AmityCoreClient.newUserRepository()
      .relationship()
      .unfollow(userId = targetUserId)
      .subscribe(
          {
              showSuccessMessage()
          },
          { error ->
              handleGeneralError(error)
          },
      )
  ```

  ```typescript TypeScript theme={null}
  import { UserRepository } from '@amityco/ts-sdk';

  const didUnfollow = await UserRepository.Relationship.unfollow(userId);

  if (didUnfollow) {
    showSuccessMessage('Unfollowed');
  }
  ```

  ```dart Flutter theme={null}
  final status = await AmityCoreClient.newUserRepository()
      .relationship()
      .unfollow(targetUserId);

  final statusValue = status.value;
  ```
</CodeGroup>

## Related Topics

<CardGroup cols={3}>
  <Card title="Accept/Decline Requests" href="./accept-decline-follow-request" icon="handshake">
    Handle incoming follow requests.
  </Card>

  <Card title="Connection Status" href="./get-connection-status" icon="signal">
    Read status and counters.
  </Card>

  <Card title="Follower Lists" href="./get-follower-following-list" icon="list">
    Query followers and following.
  </Card>
</CardGroup>
