# Item CRUD operations

## Create an item

To create an item, you must execute a `POST` request to the following endpoint:

`{baseurl}/api/default/{entity}`

Where `{entity}` is the entity of the module that you are working with.

You must specify all the properties of the item in JSON format inside the request body.

**Sample request**

> success **POST** `http://mysite.com/api/default/newsitems`

<SfDetails summary="Request body">

```JSON
{
  "Title": "Sample news item"
}
```

</SfDetails>

**Sample response**

 <SfDetails summary="Status code: 201 Created">

```JSON
{
   "@odata.context": "http://mysite.com/api/default/$metadata#newsitems/$entity",
   "Id": "f1aef86e-c13f-459b-a318-23bf8c507fe9",
   "LastModified": "2021-05-25T17:16:41Z",
   "PublicationDate": "2021-05-25T17:16:41Z",
   "Title": "Sample news item",
   "Description": "",
   "DateCreated": "2021-05-25T17:16:41Z",
   "IncludeInSitemap": true,
   "UrlName": "75fa90f6-452e-4755-b511-fc9e7534f081",
   "Category": [],
   "Tags": [],
   "AllowComments": true,
   "Summary": "",
   "Content": "",
   "Author": "",
   "SourceName": null,
   "SourceSite": null,
   "Provider": "OpenAccessDataProvider",
   "Comments": []
}
```

 </SfDetails>

## Create a draft item

To create a new item in draft state, you must execute a `POST` request to the following endpoint:

`{baseurl}/sf/system/{entity}`

Where `{entity}` is the entity of the module that you are working with.

You must specify all the properties of the item in JSON format inside the request body.

**Sample request**

> success **POST** `http://mysite.com/sf/system/newsitems`

<SfDetails summary="Request body">

```JSON
{
  "Title": "Sample news item"
}
```

</SfDetails>

**Sample response**

<SfDetails summary="Status code: 201 Created">

```JSON
{
    "@odata.context": "http://localhost:13376/sf/system/$metadata#newsitems/$entity",
    "Id": "81cd3a6e-019a-478e-9099-eda84da9fb5f",
    "LastModified": "2022-04-06T14:22:39Z",
    "PublicationDate": "2022-04-06T14:22:31Z",
    "Title": "basic news 11",
    "Description": "",
    "DateCreated": "2022-04-06T14:22:32Z",
    "IncludeInSitemap": true,
    "UrlName": "9c0d3c9a-76ef-41d8-8ac5-548b721f84f2",
    "Tags": [],
    "Category": [],
    "AllowComments": true,
    "Summary": "",
    "Content": "",
    "Author": "",
    "SourceName": null,
    "SourceSite": null,
    "Urls": [],
    "Provider": "OpenAccessDataProvider",
    "CreatedBy": "admin user",
    "LastModifiedBy": "admin user",
    "AvailableLanguages": [
        "en"
    ],
    "Comments": [],
    "LockedStatus": null,
    "DisplayStatus": [
        {
            "Name": "Draft",
            "Source": "Lifecycle",
            "Label": "Draft",
            "DetailedLabel": "Saved as draft",
            "PublicationDate": null,
            "ExpirationDate": null,
            "Date": "2022-04-06T14:22:39.56Z",
            "User": "admin user",
            "Id": null,
            "Message": {
                "Title": null,
                "Description": null,
                "Operations": []
            }
        }
    ],
    "FirstPublished": null,
    "LastPublished": null
}
```

</SfDetails>

## Get a collection of items

To get all items from a specific module, you must execute a `GET` request to the following endpoint:

`{baseurl}/api/default/{entity}`

Where `{entity}` is the entity of the module that you are working with.

**Sample request**

> success **GET** `http://mysite.com/api/default/newsitems`

**Sample response**

<SfDetails summary="Status code: 200 OK">

```JSON
{
    "@odata.context": "http://localhost:4242/api/default/$metadata#newsitems(Id,LastModified,PublicationDate,Title,Description,DateCreated,IncludeInSitemap,UrlName,AllowComments,Summary,Content,Author,SourceName,SourceSite)",
    "value": [
        {
            "Id": "fa7e8140-5a9b-478a-9312-848b206a7337",
            "LastModified": "2021-04-13T18:55:23Z",
            "PublicationDate": "2021-03-12T13:27:08Z",
            "Title": "Lorem ipsum",
            "Description": "",
            "DateCreated": "2021-03-12T13:27:08Z",
            "IncludeInSitemap": true,
            "UrlName": "lorem-ipsum",
            "AllowComments": true,
            "Summary": "",
            "Content": "",
            "Author": "",
            "SourceName": null,
            "SourceSite": null
        },
        {
            "Id": "3b177186-8b09-497c-8def-58613183d670",
            "LastModified": "2021-04-13T18:34:18Z",
            "PublicationDate": "2021-04-13T18:34:18Z",
            "Title": "Sample news item",
            "Description": "",
            "DateCreated": "2021-04-13T18:34:18Z",
            "IncludeInSitemap": true,
            "UrlName": "sample-news-item",
            "AllowComments": true,
            "Summary": "Lorem Ipsum",
            "Content": "<strong>Lorem Ipsum</strong>&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
            "Author": "",
            "SourceName": null,
            "SourceSite": null
        }
    ]
}
```

</SfDetails>

## Get an item

To get a single item, you must execute a `GET` request to the following endpoint:

`{baseurl}/api/default/{entity}({itemId})`

Where:

* `{entity}` is the entity of the module that you are working with
* `{itemId}` is the ID of the item

**Sample request**

> success **GET** `http://mysite.com/api/default/newsitems(3b177186-8b09-497c-8def-58613183d670)`

**Sample response**

<SfDetails summary="Status code: 200 OK">

```JSON
{
    "@odata.context": "http://localhost:4242/api/default/$metadata#newsitems/$entity",
    "Id": "3b177186-8b09-497c-8def-58613183d670",
    "LastModified": "2021-04-13T18:34:18Z",
    "PublicationDate": "2021-04-13T18:34:18Z",
    "Title": "Sample news item",
    "Description": "",
    "DateCreated": "2021-04-13T18:34:18Z",
    "IncludeInSitemap": true,
    "UrlName": "sample-news-item",
    "Tags": [
        "af652e26-6ac2-40f6-9e4c-da6186b4296e"
    ],
    "Category": [
        "9eee95aa-bba0-4fd6-8577-1ba1600dd284"
    ],
    "AllowComments": true,
    "Summary": "Lorem Ipsum",
    "Content": "<strong>Lorem Ipsum</strong>&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
    "Author": "",
    "SourceName": null,
    "SourceSite": null,
    "Provider": "OpenAccessDataProvider",
    "Comments": []
}
```

</SfDetails>

## Update an item

To update an item, you must execute a `PATCH` request to the following endpoint:

`{baseurl}/api/default/{entity}({itemId})`

Where:

* `{entity}` is the entity of the module that you are working with
* `{itemId}` is the ID of the item

You must specify all the properties that you want to update in JSON format inside the request body.

**Sample request**

> success **PATCH** `http://mysite.com/api/default/newsitems(f1aef86e-c13f-459b-a318-23bf8c507fe9)`

<SfDetails summary="Request body">

```JSON
{
    "Title": "Updated news item"
}
```

</SfDetails>

**Sample response**

<SfDetails summary="Status code: 204 No Content">

No response body

</SfDetails>

## Delete an item

To delete an item, you must execute a `DELETE` request to the following endpoint:

`{baseurl}/api/default/{entity}({itemId})`

Where:

* `{entity}` is the entity of the module that you are working with
* `{itemId}` is the ID of the item

**Sample request**

> success **DELETE** `http://mysite.com/api/default/newsitems(f1aef86e-c13f-459b-a318-23bf8c507fe9)`

**Sample response**

<SfDetails summary="Status code: 204 No Content">

No response body

</SfDetails>
