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.

var activity = new AddActivityRequest
{
    Type = "post",
    Text = "This is a test activity from .NET SDK",
    UserID = _testUserId,
    Feeds = new List<string> { $"user:{_testFeedId}" }
};
var response = await _feedsV3Client.AddActivityAsync(activity);

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

Image & Video

var activity = new AddActivityRequest
{
    Type = "video",
    Text = "Check out this amazing video!",
    UserID = _testUserId,
    Feeds = new List<string> { $"user:{_testFeedId}" }
    // Note: Video attachments would be added here in a real scenario
};
var response = await _feedsV3Client.AddActivityAsync(activity);

Stories

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

var tomorrow = DateTime.UtcNow.AddDays(1);
var activity = new AddActivityRequest
{
    Type = "story",
    Text = "My daily story - expires tomorrow!",
    UserID = _testUserId,
    Feeds = new List<string> { $"user:{_testFeedId}" },
    ExpiresAt = tomorrow.ToString("yyyy-MM-ddTHH:mm:ssZ"),
    Attachments = new List<Attachment>
    {
        new Attachment
        {
            ImageUrl = "https://example.com/story-image.jpg",
            Type = "image"
        },
        new Attachment
        {
            AssetUrl = "https://example.com/story-video.mp4",
            Type = "video"
        }
    },
    Custom = new Dictionary<string, object>
    {
        ["story_type"] = "daily",
        ["auto_expire"] = true
    }
};
var response = await _feedsV3Client.AddActivityAsync(activity);

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:

var activities = new List<ActivityRequest>
{
    new ActivityRequest
    {
        Type = "post",
        Text = "Batch activity 1",
        UserID = _testUserId
    },
    new ActivityRequest
    {
        Type = "post",
        Text = "Batch activity 2",
        UserID = _testUserId
    }
};

var response = await _feedsV3Client.UpsertActivitiesAsync(
    new UpsertActivitiesRequest { Activities = activities }
);

Updating & Deleting Activities

This example shows how to update or delete an activity:

var response = await _feedsV3Client.UpdateActivityAsync(
    activityId,
    new UpdateActivityRequest
    {
        Text = "Updated activity text from .NET SDK",
        UserID = _testUserId,  // Required for server-side auth
        Custom = new Dictionary<string, object>
        {
            ["updated"] = true,
            ["update_time"] = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
        }
    }
);
© Getstream.io, Inc. All Rights Reserved.