# Create Story

The SDK offers developers a suite of functions to craft stories available in two distinct types: Image and Video.

* **Image**: An Image story facilitates the use of an image file of up to 1GB,
* **Video**: A video story accommodates video files sized up to 2GB with a maximum duration of 90 seconds. The duration setting is adjustable at the network level, providing flexibility in configuration.

Each story creation offers optional StoryItems. The first supported item type, HyperLink, enables the inclusion of a URL and an alias, augmenting the story with additional content for user interaction. This feature allows seamless navigation to specified destinations upon story viewing. It's important to note that the provided URL undergoes validation by the system against a predefined whitelist, configurable at the network level.

To initiate story creation, the first step involves selecting the target type. Currently, the supported targetType is 'community,' necessitating the specification of a communityId for story creation within a specific community.

The social.plus SDK utilizes optimistic story creation behavior, resulting in three possible sync states: 'SYNCING,' 'SYNCED,' and 'FAILED.'

'SYNCING': Assigned to a locally created story during file uploads. 'SYNCED': Designated for stories successfully created on the server. 'FAILED': Applied when a story creation fails on the server.

The sync state value is accessible as a property of the story model.

## Create Image Story

The SDK provides the '`createImageStory()`' function, allowing users to create a story with an image on the specified target.

This function requires three parameters: targetType, targetId, and imageFile.

Here's an explanation of the function parameters:

* `targetType`: Represents the type of target, currently supporting 'community.'
* `targetId`: Corresponds to the ID of the designated target.
* `imageFile`: Denotes the image file intended to be attached to the story.
* `storyItems`: Additional information that can accompany the story, currently supporting a URL and its alias.
* `imageDisplayMode`: Dictates how the image should be displayed on the user interface. Either FIT or FILL.
* `metadata`: Provides support for additional properties, facilitating the use of custom fields.

{% tabs %}
{% tab title="iOS" %}
{% embed url="<https://gist.github.com/amythee/e6cdcd7c40a045f7370add16370faccd>" %}
{% endtab %}

{% tab title="Android" %}
{% embed url="<https://gist.github.com/amythee/736a5df657b495c973419861774b0955>" %}
{% endtab %}

{% tab title="TS" %}
{% embed url="<https://gist.github.com/amythee/1235031e4768437d5cd2ee97972306f2>" %}
{% endtab %}

{% tab title="Flutter" %}
{% embed url="<https://gist.github.com/amythee/173ae4b723bb2e36eb0875c0978aa4fb>" %}
{% endtab %}
{% endtabs %}

## Create Video Story

The SDK provides the '`createVideoStory()`' function, allowing users to create a story with a video on the specified target.

This function requires three parameters: targetType, targetId, and videoFile.

Here's an explanation of the function parameters:

* `targetType`: Represents the type of target, currently supporting 'community.'
* `targetId`: Corresponds to the ID of the designated target.
* `videoFile`: Denotes the video file intended to be attached to the story.
* `storyItems`: Additional information that can accompany the story, currently supporting a URL and its alias.
* `metadata`: Provides support for additional properties, facilitating the use of custom fields.

{% tabs %}
{% tab title="iOS" %}
{% embed url="<https://gist.github.com/amythee/5896e87d4f268da4081e3b2e56fdbac9>" %}
{% endtab %}

{% tab title="Android" %}
{% embed url="<https://gist.github.com/amythee/a889e97631c5897a9157e2546db0f0e2>" %}
{% endtab %}

{% tab title="TS" %}
{% embed url="<https://gist.github.com/amythee/66fa32659fa8b0264a84eb38f01a83e6>" %}
{% endtab %}

{% tab title="Flutter" %}
{% embed url="<https://gist.github.com/amythee/1d5d8610a611b4c77be844cab3c10a14>" %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.social.plus/social-plus-sdk/social/stories/create-story.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
