Skip to main content
SDK v7.x · Last verified March 2026 · iOS · Android · Web · Flutter
// 1. Create a text post
const { data: post } = await PostRepository.createPost({
  targetType: 'community', targetId: 'communityId',
  data: { text: 'Hello world!' },
});

// 2. Create an image post
const { data: imagePost } = await PostRepository.createPost({
  targetType: 'community', targetId: 'communityId',
  data: { text: 'Check this out!' },
  attachments: [{ fileId: 'uploadedFileId', type: 'image' }],
});

// 3. Create a poll post (two-step)
const { data: poll } = await PollRepository.createPoll({
  question: 'Favorite color?',
  answerType: 'single',
  answers: [{ dataType: 'text', data: 'Red' }, { dataType: 'text', data: 'Blue' }],
});
await PostRepository.createPollPost({
  pollId: poll.pollId, targetType: 'community', targetId: 'communityId',
});
Full walkthrough below ↓
Platform note — code samples below use TypeScript. Every method has an equivalent in the iOS (Swift), Android (Kotlin), and Flutter (Dart) SDKs — see the linked SDK reference in each step.
Posts are the primary unit of social content. social.plus supports 11 post types — from simple text to live streams. This guide covers how to implement creation, target posts to users or communities, and attach rich metadata.
Prerequisites: SDK installed and authenticated → SDK Setup. For image, video, or file posts: media upload configured → Media Handling. You’ll need a targetType (user or community) and targetId.Also recommended: Complete Build a Social Feed first so you can see posts appear in a feed as you create them.
After completing this guide you’ll have:
  • A post creation flow supporting text, image, video, and poll post types
  • Media upload wired up with progress tracking
  • @mentions and hashtag parsing enabled

Limits at a Glance

PropertyLimit
Max text length20,000 characters
Max images per post10
Max video size1 GB
Max file attachments10
Post typestext, image, video, file, poll, clip, livestream
Mentions per post30
Metadata size100 KB JSON

Quick Start: Create a Text Post

Use AmityPostRepository to create a text post on a community feed. The same pattern applies to all post types — just add attachments or poll data as needed. Full reference → Text Post

Step-by-Step Implementation

1

Upload media (for image/video/file posts)

For image, video, audio, and file posts, upload the media first and use the returned file ID in the post builder.
TypeScript
import { FileRepository } from '@amityco/ts-sdk';

const data = new FormData();
data.append('files', file); // file from <input type="file">

const { data: image } = await FileRepository.uploadImage(
  data,
  (percent: number) => console.log(`Upload: ${percent}%`),
);
Full reference → Image Handling · Video Handling
2

Choose the right post type

Post TypeUse CaseReference
TextStatus updates, announcementsText Post
ImagePhoto sharingImage Post
VideoVideo sharingVideo Post
AudioPodcasts, voice notesAudio Post
FileDocument sharingFile Post
PollCommunity votesPoll Post
Mixed MediaMultiple images/videosMixed Media Post
ClipShort-form video (TikTok-style)Clip Post
Live StreamLive video postsLive Stream Post
CustomAny structured dataCustom Post
Each reference page includes full multi-platform code examples (iOS, Android, TypeScript, Flutter).
3

Create image, poll, or other post types

Follow the same pattern as text posts — instantiate a post builder, set the target, attach media or data, and submit.Full reference → Image Post · Poll Post
4

Add @mentions

Mentions trigger notifications to the mentioned users. Pass user IDs alongside their text positions in the post.
TypeScript
import { PostRepository } from '@amityco/ts-sdk';

const { data: post } = await PostRepository.createPost({
  data: { text: 'Great idea @userId1!' },
  targetType: 'community',
  targetId: 'communityId',
  mentionees: [{ type: 'user', userIds: ['userId1'] }],
  metadata: {
    mentioned: [{ userId: 'userId1', type: 'user', index: 11, length: 8 }],
  },
});
Full reference → Mentions in Posts
5

Edit or delete a post

Update a post’s text, tags, or media attachments after creation. You can also soft-delete (hides from feeds) or hard-delete (permanent removal).
TypeScript
import { PostRepository } from '@amityco/ts-sdk';

// Update a post
const { data: updated } = await PostRepository.updatePost('postId', {
  data: { text: 'Updated content' },
  tags: ['tag1', 'tag2'],
});

// Soft-delete (default) — hides from feeds, recoverable
await PostRepository.deletePost('postId');

// Hard-delete — permanent removal
await PostRepository.deletePost('postId', true);
Full reference → Edit Post · Delete Post

Connect to Moderation & Analytics

The Admin Console Posts and comments management page is the central hub for moderating content. Moderators can filter posts by feed, creator, and status, and create posts directly from the console. AI moderation status is shown inline for every post.
Admin Console — Posts and comments management page
You can also create posts directly from the console — useful for platform announcements or seeded content:
Admin Console — Create post form
If your community uses ADMIN_REVIEW_POST_REQUIRED, new posts land in a review queue in the Admin Console. Moderators can approve, reject, or edit posts before they go live.Post Review · Admin Console: Posts
Enable automatic AI screening of post text and images in Admin Console → Settings → AI Content Moderation. Posts with policy violations can be auto-rejected or flagged for human review.AI Content Moderation
Track how many unique users viewed each post using impression analytics. Call markAsViewed() when a post enters the viewport.Post Impressions
Posts with product tags surface in the console with linked product cards — admins can see which products are referenced and filter posts by tag. Manage your product catalogue at Admin Console → Product catalogue.Posts with product tags visible in the Admin Console post listProduct Tagging & Social Commerce

Common Mistakes

Publishing before the file upload completes — Creating a post with an attachment before FileRepository.uploadImage() resolves produces a post with a broken media reference.
// ❌ Bad — fire and forget
FileRepository.uploadImage(blob); // no await
PostRepository.createPost({ attachments: [{ fileId: '???' }] });

// ✅ Good — wait for upload
const { data: file } = await FileRepository.uploadImage(blob);
await PostRepository.createPost({ attachments: [{ fileId: file.fileId, type: 'image' }] });
Exceeding the 20,000-character text limit — Posts with text longer than 20,000 characters are rejected by the API. Validate length in your UI before calling createPost.
Forgetting targetType and targetId — Omitting these fields creates a post on the user’s own feed. If you intend to post in a community, both fields are required.

Best Practices

  • Always show an upload progress indicator for image and video posts
  • Compress images client-side before upload (recommended max: 1MB per image)
  • Implement resumable uploads for video files over 10MB
  • Handle upload failures gracefully — store the draft locally and retry
  • Auto-save drafts so users don’t lose work if the app is backgrounded
  • Show character count for text posts (max 20,000 characters)
  • Preview images before submission
  • Give clear feedback when a post is pending review vs. immediately published
  • Use custom posts to store structured data (product cards, event summaries, etc.)
  • Always version your custom post dataType string so you can evolve the schema
  • Provide a fallback renderer for unknown custom post types

Dive deeper: Posts API Reference has full parameter tables, method signatures, and platform-specific details for every API used in this guide.

Next Steps

Your next step → Comments & Reactions

Content is live — now let users engage with threaded comments and emoji reactions.
Or explore related guides:

Comments & Reactions

Add engagement features to the posts you create

Build a Social Feed

Display posts in a feed with real-time updates

Content Moderation Pipeline

Set up review queues and AI moderation