Activity Feeds V3 is in closed alpha — do not use it in production (just yet).

Activities

Creating Activities

The example below shows how to create an activity and add it to a feed.

# Add an activity to 1 feed
activity_request = GetStream::Generated::Models::AddActivityRequest.new(
  type: 'post',
  text: 'hello world',
  user_id: 'user123',
  feeds: ['user:user123']
)

response = client.feeds.add_activity(activity_request)

# Add an activity to multiple feeds
multi_feed_request = GetStream::Generated::Models::AddActivityRequest.new(
  type: 'post',
  text: 'apple stock will go up',
  user_id: 'user123',
  feeds: ['user:1', 'stock:apple']
)

response = client.feeds.add_activity(multi_feed_request)

The above example was quite simple. Here are a few more examples:

Image & Video

# Image activity
attachment = GetStream::Generated::Models::Attachment.new(
  image_url: 'https://example.com/image.jpg',
  type: 'image',
  title: 'Test Image'
)

activity_request = GetStream::Generated::Models::AddActivityRequest.new(
  type: 'post',
  text: 'look at NYC',
  user_id: 'user123',
  feeds: ['user:user123'],
  attachments: [attachment]
)

response = client.feeds.add_activity(activity_request)

# Video activity
video_attachment = GetStream::Generated::Models::Attachment.new(
  asset_url: 'https://example.com/amazing-video.mp4',
  type: 'video',
  title: 'Amazing Video',
  custom: { duration: 120 }
)

video_request = GetStream::Generated::Models::AddActivityRequest.new(
  type: 'video',
  text: 'Check out this amazing video!',
  user_id: 'user123',
  feeds: ['user:user123'],
  attachments: [video_attachment],
  custom: {
    video_quality: '4K',
    duration_seconds: 120
  }
)

response = client.feeds.add_activity(video_request)

Stories

For a story you typically want multiple attachments and an expiration set:

tomorrow = Time.now + 86_400 # 24 hours from now

story_request = GetStream::Generated::Models::AddActivityRequest.new(
  type: 'story',
  text: 'My daily story - expires tomorrow!',
  user_id: 'user123',
  feeds: ['user:user123'],
  expires_at: tomorrow.iso8601,
  attachments: [
    GetStream::Generated::Models::Attachment.new(
      image_url: 'https://example.com/story-image.jpg',
      type: 'image'
    ),
    GetStream::Generated::Models::Attachment.new(
      asset_url: 'https://example.com/story-video.mp4',
      type: 'video',
      custom: { duration: 15 }
    )
  ],
  custom: {
    story_type: 'daily',
    auto_expire: true
  }
)

response = client.feeds.add_activity(story_request)

Overview of All Activity Fields

Here’s an overview of all the fields you can add when creating an activity:

FieldDescription
idEither set your own id, or let our server generate it. Setting your own ID can be convenient if your activity maps 1 to 1 to something in your database.
typeThe type of activity. Defaults to “post” if not provided.
feedsThe list of feeds (format: “group id:feed id”) to add this activity to
textThe text for this activity
attachmentsA list of attachments. Video, images, location, etc. Also supports custom attachments
customAny custom data you want to add
visibilityVisibility levels for the activity
locationSpecify an activity location. This allows for feeds to show content close to you. Format: ActivityLocation(lat: 40.014984, lng: -105.270546)
expiresAtWhen the activity expires. After this timestamp it’s only visible to the person who created this activity (or server side API calls)
mentionedUserIdsA list of users mentioned in this activity
parentIdThe parent activity. Used for replies/reshares etc
searchDataAny extra data you want to search on for this activity
filterTagsArray of strings that you can filter on when querying the feed
interestTagsEither set the interest tags manually or enable an activity processor to have AI determine the topics for this activity. Used for “for you” style feeds

Adding Many Activities

You can also batch add activities. Here’s an example:

activities = [
  {
    type: 'post',
    text: 'Batch activity 1',
    user_id: 'user123',
    feeds: ['user:user123']
  },
  {
    type: 'post',
    text: 'Batch activity 2',
    user_id: 'user123',
    feeds: ['user:user123']
  }
]

upsert_request = GetStream::Generated::Models::UpsertActivitiesRequest.new(
  activities: activities
)

response = client.feeds.upsert_activities(upsert_request)

Updating & Deleting Activities

This example shows how to update or delete an activity:

# Update an activity
update_request = GetStream::Generated::Models::UpdateActivityRequest.new(
  text: 'Updated activity text from Ruby SDK',
  user_id: 'user123',
  custom: {
    updated: true,
    update_time: Time.now.to_i
  }
)

response = client.feeds.update_activity(activity_id, update_request)

# Delete an activity (soft delete)
delete_request = GetStream::Generated::Models::DeleteActivityRequest.new(
  hard_delete: false  # Soft delete sets deleted at but retains the data
)

response = client.feeds.delete_activity(activity_id, delete_request)

# Batch delete activities
batch_delete_request = GetStream::Generated::Models::DeleteActivitiesRequest.new(
  activity_ids: ['123', '456'],
  hard_delete: false
)

response = client.feeds.delete_activities(batch_delete_request)
© Getstream.io, Inc. All Rights Reserved.