---
title: "Contentstack Delivery .Net SDK | V3"
description: "Documentation for Dot net Delivery SDK"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/dot-net/reference"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-11-06"
---

# Contentstack Delivery .Net SDK | V3

## Contentstack - .NET Delivery SDK | V3

## Overview

This reference covers the public API of the contentstack.csharp package, with one page per class. Use it to look up method signatures, parameters, return types, validation behavior, and worked examples for every object you reach from a ContentstackClient.

**Before you begin:** This reference assumes you have installed and initialized the SDK. If you have not, complete the [.NET Delivery SDK Get Started](/docs/developers/sdks/content-delivery-sdk/dot-net/get-started-with-dot-net-delivery-sdk) guide first. This SDK requires .NET 10 or later, because the package targets net10.0. This reference documents version 3.2.0, and the [changelog](/docs/developers/sdks/content-delivery-sdk/dot-net/dot-net-sdk-changelog) lists behavior changes between releases.

## Minimum Working Example

This snippet creates a client, fetches one entry of a content type, and prints its title.

```
using System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    Console.WriteLine(entry.Title);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## SDK Structure

The SDK uses a builder pattern. ContentstackClient stores your credentials and settings, and each call from it returns an object for a narrower scope, such as a content type, an entry, or a query. A terminal call sends the request: Fetch for a single item, Find or FetchAll for a list, Count for a total, and the Sync methods for bulk retrieval. Every chain starts at the ContentstackClient.

Because option methods store a value on the object and send nothing, an invalid argument fails on the terminal call, which throws a ContentstackException. An option method that checks its own input throws at once instead, for example on a second call that writes the same parameter. Each method page lists the exceptions it throws.

Every terminal call is async and returns a Task, so await it. The generic calls, Fetch<T> and Find<T>, bind the response to the model class you pass. Pass Entry to read fields with Get instead.

## Class Overview

**Set up the client.**

Class

Role

Accessed via

[ContentstackClient](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient)

One stack and environment, and the start of every chain.

new ContentstackClient(...)

[ContentstackOptions](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackoptions)

Every client setting in one object, including region, branch, timeout, and proxy.

new ContentstackOptions()

[ContentstackRegion](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackregion)

The region that hosts the stack.

ContentstackRegion.EU

[LivePreviewConfig](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/livepreviewconfig)

The live preview settings of a client.

options.LivePreview

[Endpoint](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/endpoint)

A static resolver of Contentstack service URLs for a region.

Endpoint.GetContentstackEndpoint(region, service)

**Read content types and entries.**

Class

Role

Accessed via

[ContentType](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contenttype)

One content type and its schema.

client.ContentType(uid)

[Entry](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/entry)

One entry of a content type.

contentType.Entry(uid)

[Query](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/query)

A filtered list of the entries of one content type.

contentType.Query()

**Read assets and global fields.**

Class

Role

Accessed via

[Asset](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/asset)

One published asset.

client.Asset(uid)

[AssetLibrary](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/assetlibrary)

The list of published assets in the stack.

client.AssetLibrary()

[GlobalField](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/global-fields)

One global field and its schema.

client.GlobalField(uid)

[GlobalFieldQuery](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/global-field-query)

The list of global fields in the stack.

client.GlobalFieldQuery()

**Read taxonomies.**

Class

Role

Accessed via

[Taxonomy](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/taxonomy)

Published taxonomies, and the entries tagged with their terms.

client.Taxonomies()

[Term](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/term)

One published term of a taxonomy.

taxonomy.Term(uid)

[TermQuery](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/termquery)

The list of published terms of one taxonomy.

taxonomy.Terms()

**Sync content, and read results and errors.**

Class

Role

Accessed via

[SyncStack](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/syncstack)

The result of a sync request, with its tokens.

client.SyncRecursive()

[SyncType](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/synctype)

The event types a sync returns.

SyncType.EntryPublished

[ContentstackCollection](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackcollection)

The items a list request returns, with the total count when you request it.

query.Find<T>()

[ContentstackException](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackexception)

The exception a failed request throws.

catch (ContentstackException e)

## Task Index

Task

Start here

Class

Fetch one entry by UID

[Fetch](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/entry#entry-fetch)

Entry

Filter entries by a field value

[Where](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/query#query-where)

Query

Page through the entries of a content type

[Skip](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/query#query-skip)

Query

Return referenced entries in full

[IncludeReference](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/entry#entry-includereference)

Entry

Read an entry in another locale

[SetLocale](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/entry#entry-setlocale)

Entry

Read an entry variant

[Variant](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/entry#entry-variant)

Entry

List the published assets in the stack

[FetchAll](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/assetlibrary#assetlibrary-fetchall)

AssetLibrary

Filter entries by a taxonomy term and the terms below it

[EqualAndBelow](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/taxonomy#taxonomy-equalandbelow)

Taxonomy

Read the schema of a content type

[Fetch](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contenttype#contenttype-fetch)

ContentType

Sync all published content, then only what changed

[SyncRecursive](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient#contentstackclient-syncrecursive)

ContentstackClient

Show draft content in live preview

[LivePreviewQueryAsync](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient#contentstackclient-livepreviewqueryasync)

ContentstackClient

Set the region, branch, timeout, or proxy

[ContentstackOptions](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackoptions)

ContentstackOptions

## Key Usage Patterns

Each example below is a complete C# file with its own using directives and client, so you can run it as a top-level program.

## Filter and sort entries into your own model class

```
using System;
using System.Linq;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // The filter and sort methods store values. Find sends the request.
    ContentstackCollection<Article> result = await client.ContentType("<CONTENT_TYPE_UID>")
        .Query()
        .Exists("url")
        .Descending("updated_at")
        .Limit(10)
        .IncludeCount()
        .Find<Article>();

    Console.WriteLine($"Showing {result.Items.Count()} of {result.Count}");
    foreach (Article article in result)
    {
        Console.WriteLine($"{article.Title}: {article.Url}");
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}

// Property names bind to response fields without regard to case.
public class Article
{
    public string Uid { get; set; }
    public string Title { get; set; }
    public string Url { get; set; }
}
```

## Page through every entry of a content type

The SDK sends one request per Find call and does not request further pages. Build a new query for each page, and stop at the Count that IncludeCount adds.

```
using System;
using System.Collections.Generic;
using System.Linq;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

const int pageSize = 25;
List<Entry> all = new List<Entry>();
int total = 0;

try
{
    do
    {
        // A new query per page, because Skip and Limit throw on a second call.
        ContentstackCollection<Entry> page = await client.ContentType("<CONTENT_TYPE_UID>")
            .Query()
            .Skip(all.Count)
            .Limit(pageSize)
            .IncludeCount()
            .Find<Entry>();

        List<Entry> items = page.Items.ToList();
        all.AddRange(items);
        total = page.Count;
        if (items.Count == 0) break;
    } while (all.Count < total);

    Console.WriteLine($"Read {all.Count} of {total} entries");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## Sync all published content, then only what changed

```
using System;
using System.Linq;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // SyncRecursive reads every page before it returns.
    SyncStack initial = await client.SyncRecursive();
    Console.WriteLine($"Published items: {initial.Items.Count()}");

    // Store SyncToken, then pass it on a later run to receive only the changes.
    SyncStack changes = await client.SyncToken(initial.SyncToken);
    Console.WriteLine($"Changed since the first sync: {changes.Items.Count()}");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## Register the client with dependency injection in ASP.NET Core

AddContentstack, from the contentstack.aspnetcore package, reads the ContentstackOptions section of your configuration and registers ContentstackClient as a transient service. In an ASP.NET Core app, pass builder.Configuration, which reads that section from appsettings.json. Each key in the section matches a ContentstackOptions property, for example ApiKey, DeliveryToken, and Environment.

The file below registers the client and a service class that receives it through its constructor.

```
using System;
using System.Threading.Tasks;
using Contentstack.AspNetCore;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

public static class ContentstackSetup
{
    // Call from Program.cs: ContentstackSetup.AddServices(builder.Services, builder.Configuration)
    public static void AddServices(IServiceCollection services, IConfigurationRoot configuration)
    {
        services.AddContentstack(configuration);
        services.AddTransient<ArticleService>();
    }
}

// The container passes a new ContentstackClient built from the bound options.
public class ArticleService
{
    private readonly ContentstackClient _client;

    public ArticleService(ContentstackClient client)
    {
        _client = client;
    }

    public async Task<string> GetTitleAsync(string entryUid)
    {
        try
        {
            Entry entry = await _client.ContentType("<CONTENT_TYPE_UID>").Entry(entryUid).Fetch<Entry>();
            return entry.Title;
        }
        catch (ContentstackException e)
        {
            Console.WriteLine(e.Message);
            return null;
        }
    }
}
```

## Retry a rate-limited request with a delay

The SDK sends each request once. Catch a 429 status and send the request again after a delay that grows with each attempt.

```
using System;
using System.Net;
using System.Threading.Tasks;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

const int maxAttempts = 3;
Entry entry = null;

for (int attempt = 1; attempt <= maxAttempts && entry == null; attempt++)
{
    try
    {
        entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    }
    catch (ContentstackException e) when (e.StatusCode == HttpStatusCode.TooManyRequests && attempt < maxAttempts)
    {
        // Wait one second, then two, before the next attempt.
        await Task.Delay(TimeSpan.FromSeconds(attempt));
    }
    catch (ContentstackException e)
    {
        Console.WriteLine(e.Message);
        break;
    }
}

Console.WriteLine(entry?.Title);
```

## Tell a network failure from an API rejection

A timeout or DNS failure produces no API error body, so ErrorCode stays 0 and StatusCode reports 500 although no server sent it. Check ErrorCode before you trust StatusCode.

```
using System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    Console.WriteLine(entry.Title);
}
catch (ContentstackException e) when (e.ErrorCode == 0)
{
    // No API error body: a timeout, a DNS failure, or a response the SDK could not process
    Console.WriteLine($"Request did not complete: {e.Message}");
}
catch (ContentstackException e)
{
    // The API answered and rejected the request
    Console.WriteLine($"API error: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## SDK-Wide Notes

Concern

Behavior

Default when unset

Authentication

The ContentstackClient constructor takes the API key, delivery token, and environment, and every object the client creates sends them. No other method takes credentials.

Not applicable. The constructor does not validate the three values, so a missing or wrong value fails at the first request.

Error surfacing

Every request method throws a ContentstackException, or one of its subclasses, when the request fails. Read Message, ErrorCode, StatusCode, and Errors. The [ContentstackException](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackexception) class page lists which call throws which subclass.

Not applicable. A timeout or DNS failure throws with StatusCode 500 and ErrorCode 0.

Regions and endpoints

Set Region on ContentstackOptions, or pass region to the constructor: US, EU, AU, AZURE\_NA, AZURE\_EU, GCP\_NA, or GCP\_EU. The client resolves the delivery host for the region through the [Endpoint](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/endpoint) class, from regions.json. A Host value overrides the region.

ContentstackRegion.US, which resolves to cdn.contentstack.io.

Branches

Set Branch on ContentstackOptions. The SDK sends it as the branch header on every request.

No branch header, so the API applies its default.

Rate limiting and retry

This SDK does not auto-retry on 429, so implement backoff in your calling code. It also sends a request once when the response is a 5xx status or the request times out.

No retry.

Timeouts

Set Timeout on ContentstackOptions, or pass timeout to the constructor, in milliseconds. A request that times out throws a ContentstackException with StatusCode 500 and ErrorCode 0.

30000 ms.

Proxy configuration

Set Proxy on ContentstackOptions, or pass proxy to the constructor. **Known issue:** Query.Find, Query.FindOne, and Query.Count do not use it. See the [Query](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/query) class page.

null.

Request URL encoding

The SDK adds query values to the request URL without URL encoding them. A value that holds & or # changes the request URL, so avoid those characters in filter and parameter values.

Not applicable. The SDK never encodes values.

Option methods

Option methods store their value on the object that sends the request, and no method removes a stored option. On most classes, a second call that writes the same parameter throws. Build a new object for each request with different options.

Each new object starts with no options.

JSON binding

The SDK parses responses with System.Text.Json. Fetch<T> and Find<T> bind response fields to your model class without regard to case. Add converters to client.SerializerOptions.Converters before the first request.

SerializerOptions with case-insensitive property names and the SDK's own converters.

Dependency injection

services.AddContentstack(configuration), from the contentstack.aspnetcore package, binds the ContentstackOptions configuration section and registers ContentstackClient as a transient service.

Not applicable. Without it, create the client with a constructor.

**Warning:** This SDK requires a delivery token, which the client sends as the access\_token header. The constructor does not check the token, so a management token or a preview token in its place fails at the first request with a ContentstackException. Pass a preview token in LivePreviewConfig.PreviewToken instead. Refer to [Content Delivery API Errors](/docs/developers/apis/content-delivery-api#errors) for the full error code list.

## SDK Limitations

Capability

Supported

Notes / Alternative

Retry a rate-limited or failed request

No

Catch ContentstackException, check StatusCode, and send the request again after a delay, as in Key Usage Patterns above.

Read every page of a list in one call

No

Loop with Skip and Limit on a new query per page, as in Key Usage Patterns above. SyncRecursive is the exception, and reads every page of a sync.

Reuse one request object for a request with different options

No

Most option methods throw on a second call. Build a new object from the client for each request.

Encode special characters in query values

No

Avoid & and # in filter and parameter values.

## ContentstackOptions

ContentstackOptions holds every setting of a ContentstackClient in one object, in the Contentstack.Core.Configuration namespace. Use this class to

*   create a client with settings that the string constructor does not take, such as Branch, LivePreview, and EarlyAccessHeader
*   bind client settings from configuration, such as an appsettings.json section, through the .NET options pattern

Set the properties, then pass the object to the ContentstackClient(ContentstackOptions options) constructor. See the [ContentstackClient](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient) class page for the constructors.

## ContentstackOptions

The api key used when communicating with the Contentstack API.

The access token used when communicating with the Contentstack API.

The delivery token used when communicating with the Contentstack API.

The environment used when communicating with the Contentstack API.

The Branch used to set Branch for the Contentstack API.

The Host used to set host url for the Contentstack API.

The Region used to set region for the Contentstack API.

The Version number for the Contentstack API.

The Live preview configuration for the Contentstack API.

API key of the stack. Sent as the api\_key header.

Delivery token for the environment. Sent as the access\_token header.

Environment to read published content from.

Region that hosts the stack. Ignored when Host holds a value.

Custom delivery host, without a scheme. Overrides Region.

API version path segment. The SDK uses v3 when unset.

Branch to read content from. Sent as the branch header on every request.

Request timeout in milliseconds.

Proxy for outgoing requests.

Live preview settings. Live preview stays off when unset.

Early access feature names. Sent as one comma-separated x-header-ea header.

Deprecated. Use DeliveryToken.

## ContentstackOptions | .NET Delivery SDK | Contentstack

The ContentstackOptions class in the .NET Delivery SDK holds every client setting, including credentials, region, host, branch, timeout, proxy, and live preview.

## LivePreviewConfig

LivePreviewConfig holds the live preview settings of a client, in the Contentstack.Core.Configuration namespace. With live preview on, entry fetches and queries return the draft content that an editor previews, in place of the published content. Use this class to

*   turn live preview on for a client
*   give the client the preview token or management token that preview requests need
*   preview a release, or content at a point in time

Assign the object to ContentstackOptions.LivePreview, then create the client. Read it back later with the [GetLivePreviewConfig](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient#contentstackclient-getlivepreviewconfig) method.

## LivePreviewConfig

To enable live preview

Host for getting live preview content

Management Token for the stack to get content

Turns live preview on for the client.

Preview token. Sent as the preview\_token header.

Management token. Sent as the authorization header, and used in place of PreviewToken.

Live preview host, without a scheme. The constructor fills it when empty.

Release to preview. Sent as the release\_id header.

Point in time to preview. Sent as the preview\_timestamp header.

## LivePreviewConfig | .NET Delivery SDK | Contentstack

The LivePreviewConfig class in the .NET Delivery SDK turns on live preview and holds the preview token, host, release, and timestamp the client uses for draft content.

## ContentstackRegion

ContentstackRegion is an enum, in the Contentstack.Core.Internals namespace, that names the region where your stack lives. The client uses it to choose the Content Delivery host. Use this enum to

*   point a client at a stack outside North America
*   pass a region to the region argument of a ContentstackClient constructor, or to ContentstackOptions.Region

The default is ContentstackRegion.US.

## ContentstackRegion

## ContentstackRegion | .NET Delivery SDK | Contentstack

The ContentstackRegion enum in the .NET Delivery SDK lists the regions a stack can live in, and selects the delivery host a client sends requests to.

## ContentstackCollection

ContentstackCollection<T> holds the items that a list request returns, in the Contentstack.Core.Models namespace. It implements IEnumerable<T>, so you can loop over it with foreach or query it with LINQ. Use this class to

*   read the entries, assets, taxonomies, or terms a list request returns
*   read the total number of matches when you request a count

Query.Find<T>, Query.FindOne<T>, AssetLibrary.FetchAll, Taxonomy.Find<T>, and TermQuery.Find<T> return a Task<ContentstackCollection<T>>. T is the model type you pass to the call, such as Entry or your own class.

## ContentstackCollection<T>

The total number of items available.

The System.Collections.Generic.IEnumerable<T> of items to be serialized from the API response.

The maximum number of items returned in this result.

The number of items skipped in this resultset.

The items the request returned.

Total number of matches. Filled only when you request a count.

Always 0 in a response from the Content Delivery API.

Always 0 in a response from the Content Delivery API.

## ContentstackCollection | .NET Delivery SDK | Contentstack

The ContentstackCollection class in the .NET Delivery SDK holds the items a query or asset listing returns, with the total count when you request it.

## ContentstackException

ContentstackException is the exception the SDK throws when a request fails, in the Contentstack.Core.Internals namespace. It extends System.Exception and is the base class of seven more specific exceptions. Use this class to

*   catch every request failure from the SDK in one catch block
*   read the API error code, the HTTP status, and the per-field messages of a rejected request

Catch ContentstackException unless your code handles one failure differently from another. Every subclass below carries the same properties.

## ContentstackException

This is error message.

Set of errors in detail.

Read-only. The API's error\_message, or a description of the failure.

The API's error\_code. 0 when no API error body arrived.

The HTTP status of the response.

The API's errors object: one list of messages per field.

## ContentstackException | .NET Delivery SDK | Contentstack

The ContentstackException class in the .NET Delivery SDK carries the error message, error code, HTTP status, and field errors when a request fails, and is the base of seven subclasses.

## SyncStack

SyncStack holds the result of a sync request, in the Contentstack.Core.Models namespace. Every sync method on the client returns one. Use this class to

*   read the published, unpublished, and deleted items a sync returns
*   read the token for the next sync request

[SyncRecursive](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient#contentstackclient-syncrecursive), [SyncToken](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient#contentstackclient-synctoken), and [SyncPaginationToken](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient#contentstackclient-syncpaginationtoken) return a Task<SyncStack>.

## SyncStack

Readonly property contains all the Contents

Readonly property for paginating sync

Readonly property to delta sync.

Readonly property to check totalCount

The sync items. Each one is a JsonElement.

The total\_count value of the response.

Token for the next sync. Set on the last page.

Token for the next page. Set while pages remain.

## SyncStack | .NET Delivery SDK | Contentstack

The SyncStack class in the .NET Delivery SDK holds the result of a sync request: the synced items, the total count, and the token for the next request.

## SyncType

SyncType is a flags enum, in the Contentstack.Core.Internals namespace, that selects which events a sync returns. The SDK sends your selection as the type parameter of the [Initial Sync](/docs/developers/apis/content-delivery-api/synchronization#initial-sync) request. Use this enum to

*   sync only published content, or only deletions
*   limit a sync to entries or to assets

Pass it to the SyncType argument of the [SyncRecursive](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient#contentstackclient-syncrecursive) method. The default there is SyncType.All.

## SyncType

## SyncType | .NET Delivery SDK | Contentstack

The SyncType flags enum in the .NET Delivery SDK selects which publish, unpublish, and delete events a sync returns.

## ContentstackClient

ContentstackClient is the entry point of the .NET Delivery SDK. It holds the stack credentials, the environment, and the request settings, and every other object in the SDK starts from it. Use this class to

*   connect to one stack and one environment
*   reach content types, entries, assets, global fields, and taxonomies
*   retrieve published content in bulk through the Sync API
*   set request headers and live preview values that later requests carry

## Asset

Asset returns an object for the asset that a UID names.

```
Returns: Asset. A new asset object.
ValidationThere is no client-side validation. Asset accepts a null or empty UID and stores it as given.A null or empty UID fails when Fetch sends the request, with an AssetException.Errors that do occur come from the Fetch call that follows, not from Asset.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Asset builds the object and makes no request.The asset object uses the client's credentials, environment, branch, and headers.Call Fetch on the result to read the asset. See the Asset class page for the methods you can chain.To read many assets, use the AssetLibrary method instead.ExampleBasic usage: fetch one asset by UIDusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").Fetch();
    Console.WriteLine($"{asset.FileName}: {asset.Url}");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

UID of the asset to read.

## AssetLibrary

AssetLibrary returns a query across every asset in the stack.

```
Returns: AssetLibrary. A new asset library object.
ValidationThere is no client-side validation, because AssetLibrary takes no argument.Errors that do occur come from the FetchAll or Count call that follows, not from AssetLibrary.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. AssetLibrary builds the query object and makes no request.Each call returns a new object, so filters you chain on one asset library object do not reach another.Chain filters such as Limit or Tags, then call FetchAll to read the matching assets. See the AssetLibrary class page for the full set.To read one asset by its UID, use the Asset method instead.ExampleBasic usage: list the first ten assetsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary().Limit(10).FetchAll();
    foreach (Asset asset in assets)
    {
        Console.WriteLine($"{asset.Uid}: {asset.FileName}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## ContentType

ContentType returns an object for one content type, from which you reach its schema, its entries, and its queries.

```
Returns: ContentType. A new content type object.
ValidationThere is no client-side validation. ContentType accepts a null or empty UID and stores it as given.A null or empty UID fails on the terminal call (Fetch or Find) that follows, with a ContentstackException subclass.Errors that do occur come from that terminal call, not from ContentType.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. ContentType builds the object and makes no request.Pass the content type UID, not its display title. The SDK places the value of contentTypeName in the request URL.When the UID is not empty, ContentType records it on the client. LivePreviewQueryAsync uses that UID when its dictionary has no content_type_uid key.Chain Entry("<ENTRY_UID>") to read one entry, Query() to search entries, or Fetch() to read the content type schema. See the ContentType class page.To list every content type in the stack, use the GetContentTypes method instead.ExampleBasic usage: fetch one entry of a content typeusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    Console.WriteLine(entry.Title);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Query entries: find the first five entries of a content typeusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> entries = await client.ContentType("<CONTENT_TYPE_UID>").Query().Limit(5).Find<Entry>();
    foreach (Entry entry in entries)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID of the content type to work with.

## GetAccessToken

GetAccessToken returns the delivery token that the client sends in the access\_token header.

```
Returns: string. The delivery token the client sends.
ValidationThrows KeyNotFoundException if the client holds no access_token header, because GetAccessToken reads that header directly. This happens when you create the client without a delivery token, or after RemoveHeader("access_token").BehaviorClient-side only. GetAccessToken reads the header the constructor wrote and makes no request.The constructor writes DeliveryToken into the access_token header. When the deprecated AccessToken option also holds a value, the constructor writes that value instead.A later SetHeader("access_token", ...) call changes the value that GetAccessToken returns.ExampleBasic usage: read the delivery token backusing System;
using Contentstack.Core;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

string token = client.GetAccessToken();
Console.WriteLine($"Token length: {token.Length}");Edge case: the header is missingusing System;
using System.Collections.Generic;
using Contentstack.Core;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
client.RemoveHeader("access_token");

try
{
    string token = client.GetAccessToken();
}
catch (KeyNotFoundException)
{
    // Thrown when the client holds no access_token header
    Console.WriteLine("The client has no delivery token.");
}
```

## GetApplicationKey

GetApplicationKey returns the stack API key that you passed to the constructor.

```
Returns: string. The API key the client holds.
ValidationThere is no client-side validation. GetApplicationKey returns null when you created the client without an API key.BehaviorClient-side only. GetApplicationKey reads the value the constructor stored and makes no request.GetApplicationKey returns the constructor value even after SetHeader("api_key", ...) changes the header that requests carry.ExampleBasic usage: read the API key backusing System;
using Contentstack.Core;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

string apiKey = client.GetApplicationKey();
Console.WriteLine($"API key: {apiKey}");
```

## GetContentTypes

GetContentTypes retrieves every content type in the stack, with its schema.

```
Returns: Task<IList>. The content types in the stack.
ValidationThere is no client-side validation of the keys or values in param.Throws ArgumentException if param holds an environment key, because the SDK adds environment from the client first and the request parameters cannot hold the same key twice. The exception occurs before the SDK sends anything.Throws ContentstackException if the API rejects the request. GetContentTypes throws the base class, not ContentTypeException.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorSends one GET /content_types request with the client's environment, and adds each param entry as a query parameter. See Get all content types.The API reference documents include_branch and include_global_field_schema for this request. include_global_field_schema returns the schema of each global field inside the content type schema.The SDK writes each value with its default string form, so the bool value true reaches the API as True. Pass flags as the string "true".Returns the content_types array only. Each item is a Dictionary<string, object>, and nested objects and arrays arrive as further dictionaries and List<object> values.GetContentTypes drops every other key in the response. A count that include_count adds does not reach you.To read one content type, use the ContentType method and call Fetch on the result.ExampleBasic usage: list content type UIDs and titlesusing System;
using System.Collections;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    IList contentTypes = await client.GetContentTypes();
    foreach (Dictionary<string, object> contentType in contentTypes)
    {
        Console.WriteLine($"{contentType["uid"]}: {contentType["title"]}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}All parameters: include global field schemas and branch detailsusing System;
using System.Collections;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

// Pass flag values as strings. A bool reaches the API as "True".
Dictionary<string, object> param = new Dictionary<string, object>()
{
    { "include_global_field_schema", "true" },
    { "include_branch", "true" }
};

try
{
    IList contentTypes = await client.GetContentTypes(param);
    foreach (Dictionary<string, object> contentType in contentTypes)
    {
        List<object> schema = (List<object>)contentType["schema"];
        Console.WriteLine($"{contentType["uid"]}: {schema.Count} fields");
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Extra query parameters for the request.

## GetEnvironment

GetEnvironment returns the environment that the client reads published content from.

```
Returns: string. The environment the client reads content from.
ValidationThere is no client-side validation. GetEnvironment returns null when you created the client without an environment.BehaviorClient-side only. GetEnvironment reads the value the constructor stored and makes no request.The SDK sends this value as the environment query parameter. SyncToken and SyncPaginationToken leave it out. The All Query Parameters reference lists environment for every Content Delivery API request except those two sync requests.ExampleBasic usage: read the environment backusing System;
using Contentstack.Core;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

string environment = client.GetEnvironment();
Console.WriteLine($"Environment: {environment}");
```

## GetLivePreviewConfig

GetLivePreviewConfig returns the live preview settings object that the client uses for its requests.

```
Returns: LivePreviewConfig. The live preview settings the client uses.
ValidationThere is no client-side validation, because GetLivePreviewConfig takes no argument. It never returns null.BehaviorClient-side only. GetLivePreviewConfig makes no request.Returns the same object the client holds, not a copy. A change to a property of the returned object, such as PreviewToken, applies to the next request.When you created the client without ContentstackOptions.LivePreview, the object has Enable set to false.When live preview is on and you left Host unset, the constructor filled Host in. Read it here to see which host the client uses.See the LivePreviewConfig class page for each property.ExampleBasic usage: check the live preview hostusing System;
using Contentstack.Core;
using Contentstack.Core.Configuration;

ContentstackClient client = new ContentstackClient(new ContentstackOptions()
{
    ApiKey = "<API_KEY>",
    DeliveryToken = "<DELIVERY_TOKEN>",
    Environment = "<ENVIRONMENT>",
    LivePreview = new LivePreviewConfig()
    {
        Enable = true,
        PreviewToken = "<PREVIEW_TOKEN>"
    }
});

LivePreviewConfig config = client.GetLivePreviewConfig();
Console.WriteLine($"Live preview enabled: {config.Enable}, host: {config.Host}");
```

## GetVersion

GetVersion returns the API version path segment that the client puts in every request URL.

```
Returns: string. The API version segment the client uses.
ValidationThere is no client-side validation, because GetVersion takes no argument.BehaviorClient-side only. GetVersion reads the client configuration and makes no request.Returns v3 unless you passed a version to the constructor or set ContentstackOptions.Version.GetVersion returns the API version, not the SDK package version.ExampleBasic usage: read the API versionusing System;
using Contentstack.Core;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

string version = client.GetVersion();
Console.WriteLine($"API version: {version}");
```

## GlobalField

GlobalField returns an object for the global field that a UID names.

```
Returns: GlobalField. A new global field object.
ValidationThrows GlobalFieldException at once if globalFieldName is an empty string, because the global field object rejects an empty UID.A null UID passes this check and fails when Fetch sends the request.Errors from the API come from the Fetch call that follows, not from GlobalField.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. GlobalField builds the object and makes no request.Pass the global field UID, not its display title. The SDK places the value in the request URL.Call Fetch on the result to read the global field schema. See the Global Fields class page.To read every global field, use the GlobalFieldQuery method instead.ExampleBasic usage: fetch one global field schemausing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject globalField = await client.GlobalField("<GLOBAL_FIELD_UID>").Fetch();
    Console.WriteLine(globalField["title"]);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

UID of the global field to read.

## GlobalFieldQuery

GlobalFieldQuery returns a query across every global field in the stack.

```
Returns: GlobalFieldQuery. A new global field query.
ValidationThere is no client-side validation, because GlobalFieldQuery takes no argument.Errors that do occur come from the Find call that follows, not from GlobalFieldQuery.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. GlobalFieldQuery builds the query object and makes no request.Call Find on the result to read the global fields. See the Global Field Query class page.To read one global field by its UID, use the GlobalField method instead.ExampleBasic usage: list every global fieldusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject response = await client.GlobalFieldQuery().Find();
    JsonArray globalFields = response["global_fields"]?.AsArray();
    Console.WriteLine($"Global fields: {globalFields?.Count ?? 0}");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## LivePreviewQueryAsync

LivePreviewQueryAsync stores the live preview values from a preview request on the client. The next entry fetch or query for that content type then returns the draft content.

```
Returns: Task. A task that completes when the client holds the preview values.
ValidationThrows NullReferenceException if query is null, because LivePreviewQueryAsync reads the dictionary keys without a null check.There is no check on the values. An empty or wrong hash reaches the API on the next Fetch or Find.LivePreviewQueryAsync ignores keys it does not recognize.Errors that do occur come from the Entry.Fetch or Query.Find call that follows.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. LivePreviewQueryAsync writes into the client's LivePreviewConfig and makes no request. The returned task has already completed.LivePreviewQueryAsync reads the five keys below from query:live_preview: the preview hash. When the key is missing, the client clears the hash.content_type_uid: the content type to preview. When the key is missing, the client uses the UID from the last ContentType call.entry_uid: the entry to preview. When the key is missing, the client uses the UID from the last SetEntryUid call.release_id: sent as the release_id header. When the key is missing, the client clears it.preview_timestamp: sent as the preview_timestamp header. When the key is missing, the client clears it.The values take effect only when LivePreviewConfig.Enable is true.When the client holds a hash, Entry.Fetch and Query.Find on the matching content type send the request to LivePreviewConfig.Host with the hash. They send the preview token (or the management token as authorization) in place of the delivery token.Requests for every other content type, and every request while the client holds no hash, go to the delivery host as usual.The values live on the client. Two preview requests that share one client overwrite each other's values, so create a client for each incoming preview request.ExampleBasic usage: preview the entry that the preview URL namesusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Configuration;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient(new ContentstackOptions()
{
    ApiKey = "<API_KEY>",
    DeliveryToken = "<DELIVERY_TOKEN>",
    Environment = "<ENVIRONMENT>",
    LivePreview = new LivePreviewConfig()
    {
        Enable = true,
        PreviewToken = "<PREVIEW_TOKEN>"
    }
});

// In a web app, read the hash from the preview request's query string.
string livePreviewHash = Environment.GetEnvironmentVariable("LIVE_PREVIEW_HASH") ?? "";

await client.LivePreviewQueryAsync(new Dictionary<string, string>()
{
    { "live_preview", livePreviewHash },
    { "content_type_uid", "<CONTENT_TYPE_UID>" },
    { "entry_uid", "<ENTRY_UID>" }
});

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    Console.WriteLine(entry.Title);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Preview a release at a point in timeusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Configuration;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient(new ContentstackOptions()
{
    ApiKey = "<API_KEY>",
    DeliveryToken = "<DELIVERY_TOKEN>",
    Environment = "<ENVIRONMENT>",
    LivePreview = new LivePreviewConfig()
    {
        Enable = true,
        PreviewToken = "<PREVIEW_TOKEN>"
    }
});

// In a web app, read each value from the preview request's query string.
Dictionary<string, string> previewQuery = new Dictionary<string, string>()
{
    { "live_preview", Environment.GetEnvironmentVariable("LIVE_PREVIEW_HASH") ?? "" },
    { "content_type_uid", "<CONTENT_TYPE_UID>" },
    { "entry_uid", "<ENTRY_UID>" },
    { "release_id", Environment.GetEnvironmentVariable("LIVE_PREVIEW_RELEASE_ID") ?? "" },
    { "preview_timestamp", Environment.GetEnvironmentVariable("LIVE_PREVIEW_TIMESTAMP") ?? "" }
};

await client.LivePreviewQueryAsync(previewQuery);

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    Console.WriteLine(entry.Title);
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Live preview values from the preview URL.

## RemoveHeader

RemoveHeader removes a header from the requests that objects created from this client send.

```
Returns: void. This method returns nothing.
ValidationThrows ArgumentNullException if key is null, because the SDK stores headers in a dictionary that rejects a null key.A name the client does not hold is not an error. RemoveHeader does nothing in that case.Header names match exactly, including case. RemoveHeader("Branch") does not remove a header you set as branch.BehaviorClient-side only. RemoveHeader changes the client's header dictionary and makes no request.The constructor writes api_key and access_token into the same dictionary. Removing either one removes it from later requests, and the API then rejects those requests.After RemoveHeader("access_token"), the GetAccessToken method throws KeyNotFoundException.Use the SetHeader method to add the header back.ExampleBasic usage: stop sending a custom headerusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
client.SetHeader("x-request-source", "catalog-sync");

// Later requests no longer carry x-request-source.
client.RemoveHeader("x-request-source");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    Console.WriteLine(entry.Title);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the header to remove.

## SetEntryUid

SetEntryUid stores an entry UID on the client for live preview.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation that raises an error. SetEntryUid ignores a null or empty value and keeps the UID it held before.BehaviorClient-side only. SetEntryUid stores the UID and makes no request.LivePreviewQueryAsync copies the stored UID into the live preview settings when its dictionary has no entry_uid key.ContentType.Entry("<ENTRY_UID>") calls SetEntryUid for you, so the stored UID is usually the last entry you created an object for.No request reads the stored entry UID. Live preview applies to the entry you fetch, so the stored UID does not change which entry a request returns.ExampleBasic usage: store the entry UID before a preview requestusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Configuration;

ContentstackClient client = new ContentstackClient(new ContentstackOptions()
{
    ApiKey = "<API_KEY>",
    DeliveryToken = "<DELIVERY_TOKEN>",
    Environment = "<ENVIRONMENT>",
    LivePreview = new LivePreviewConfig()
    {
        Enable = true,
        PreviewToken = "<PREVIEW_TOKEN>"
    }
});

client.SetEntryUid("<ENTRY_UID>");

// The dictionary has no entry_uid key, so the client uses the stored UID.
await client.LivePreviewQueryAsync(new Dictionary<string, string>()
{
    { "live_preview", Environment.GetEnvironmentVariable("LIVE_PREVIEW_HASH") ?? "" },
    { "content_type_uid", "<CONTENT_TYPE_UID>" }
});
Console.WriteLine("Preview values stored.");
```

UID of the entry to preview.

## SetHeader

SetHeader adds a header to the requests that objects created from this client send, or replaces the value of a header the client already holds.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation that raises an error. When key or value is null, SetHeader ignores the call and keeps the previous value.A name or value that .NET rejects as an HTTP header does not raise an error either. The SDK drops that header when it builds each request.BehaviorClient-side only. SetHeader changes the client's header dictionary and makes no request.Setting a name the client already holds replaces its value. Header names match exactly, including case.The constructor writes api_key and access_token into the same dictionary, so SetHeader("access_token", ...) replaces the delivery token on later requests.The header reaches requests from the objects you create after the call. Set client headers before you create content type, asset, or taxonomy objects.Use the RemoveHeader method to stop sending a header.ExampleBasic usage: send a custom header with every requestusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
client.SetHeader("x-request-source", "catalog-sync");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    Console.WriteLine(entry.Title);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Read from a branch for this client onlyusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

// The Content Delivery API reads the branch from the branch header.
client.SetHeader("branch", "<BRANCH>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    Console.WriteLine(entry.Title);
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Name of the header to send.

Value to send for that header.

## SyncPaginationToken

SyncPaginationToken retrieves the next page of a sync, using the pagination token from the previous page.

```
Returns: Task<SyncStack>. The next page of sync items.
ValidationThere is no client-side validation. A null token sends a request without pagination_token, and the API rejects it because the request needs that parameter.Throws ContentstackException if the API rejects the request. SyncPaginationToken throws the base class, not a subclass.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorSends one Sync using pagination token request, GET /stacks/sync with pagination_token. The request carries no environment.The API returns up to 100 items per page.The response carries a PaginationToken while more pages remain, and a SyncToken on the last page. Store the sync token for the SyncToken method.SyncRecursive calls SyncPaginationToken for you. Call it yourself after the SyncToken method, or to read a large sync one page at a time.ExampleBasic usage: read the next pageusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    SyncStack page = await client.SyncPaginationToken("<PAGINATION_TOKEN>");
    if (page.PaginationToken != null)
    {
        Console.WriteLine($"More pages remain. Next token: {page.PaginationToken}");
    }
    else
    {
        Console.WriteLine($"Last page. Save this sync token: {page.SyncToken}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Pagination token from the previous sync response.

## SyncRecursive

SyncRecursive starts a sync of the published content in the environment and reads every page of the result before it returns.

```
Returns: Task<SyncStack>. Every item the sync returns, across all pages.
ValidationThere is no client-side validation. Every argument is optional, and SyncRecursive() with no arguments syncs every published entry and asset in the environment.SyncRecursive writes StartFrom as given and appends Z, without converting it to UTC. Pass a UTC value, such as DateTime.UtcNow.AddDays(-7). A local time reaches the API offset by your time zone.SyncType.Default sets no event type, so the SDK sends an empty type parameter. Use SyncType.All to include every event type.Throws ContentstackException if the API rejects any request in the sequence. SyncRecursive throws the base class, not a subclass, and returns none of the pages it already read.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorSends the Initial Sync request, GET /stacks/sync with init=true and the client's environment.The arguments map to the locale, type, content_type_uid, and start_from query parameters. The SDK leaves out each one you do not pass, apart from type.SyncType is a flags enum. Combine values with |, and the SDK sends them as a comma-separated type list. SyncType.All, alone or combined, sends all seven event types. See the SyncType class page.While the response carries a pagination token, SyncRecursive calls the SyncPaginationToken method and appends the new items. Each page is one request, and the API returns up to 100 items per page, as Sync using pagination token describes.The returned SyncStack holds every item, a SyncToken for the next sync, and a null PaginationToken.Each item in Items is a System.Text.Json.JsonElement that holds one item of the API response as the API returns it. Read its fields with TryGetProperty.Store SyncToken and pass it to the SyncToken method later to receive only the changes.LimitationsDoes not return the first page alone. A large stack produces many requests before SyncRecursive returns. Narrow the sync with ContentTypeUid, Locale, SyncType, or StartFrom.Does not resume an earlier sync. Use the SyncToken method for that.ExampleBasic usage: sync everything published in the environmentusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    SyncStack result = await client.SyncRecursive();
    Console.WriteLine($"Items: {result.TotalCount}. Save this sync token: {result.SyncToken}");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}All parameters: sync published entries and assets of one content type and locale from last weekusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    SyncStack result = await client.SyncRecursive(
        Locale: "<LOCALE>",
        SyncType: SyncType.EntryPublished | SyncType.AssetPublished,
        ContentTypeUid: "<CONTENT_TYPE_UID>",
        // StartFrom must be UTC. The SDK does not convert a local time.
        StartFrom: DateTime.UtcNow.AddDays(-7));
    Console.WriteLine($"Items: {result.TotalCount}");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}Read the items: each one is a JsonElementusing System;
using System.Text.Json;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    SyncStack result = await client.SyncRecursive(SyncType: SyncType.EntryPublished);
    foreach (JsonElement item in result.Items)
    {
        // Each item describes one publish, unpublish, or delete event.
        if (item.TryGetProperty("type", out JsonElement eventType))
        {
            Console.WriteLine(eventType.GetString());
        }
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Locale code to restrict the sync to.

Event types to include in the sync.

Content type to restrict the sync to.

Earliest publish date to include, in UTC.

## SyncToken

SyncToken retrieves the publish, unpublish, and delete events since an earlier sync, using the sync token that sync returned.

```
Returns: Task<SyncStack>. The content that changed since the last sync.
ValidationThere is no client-side validation. A null token sends a request without sync_token, and the API rejects it because the request needs that parameter.Throws ContentstackException if the API rejects the request, for example for an expired or unknown token. SyncToken throws the base class, not a subclass.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorSends one Subsequent Sync request, GET /stacks/sync with sync_token. The request carries no environment.SyncToken reads one page only. When the changes exceed 100 items, the response carries a PaginationToken in place of a SyncToken.Pass that pagination token to the SyncPaginationToken method until a response carries a SyncToken. Store that token for the next sync.See the SyncStack class page for the fields of the result.ExampleBasic usage: read the changes since the last syncusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    SyncStack result = await client.SyncToken("<SYNC_TOKEN>");
    Console.WriteLine($"Changed items on this page: {result.TotalCount}");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Read every page of the changesusing System;
using System.Collections.Generic;
using System.Linq;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    SyncStack page = await client.SyncToken("<SYNC_TOKEN>");
    List<dynamic> changes = page.Items.ToList();

    // A pagination token means more pages remain.
    while (page.PaginationToken != null)
    {
        page = await client.SyncPaginationToken(page.PaginationToken);
        changes.AddRange(page.Items);
    }

    Console.WriteLine($"Changed items: {changes.Count}. Next sync token: {page.SyncToken}");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Sync token from the previous completed sync.

## Taxonomies

Taxonomies returns a taxonomy object that covers every taxonomy in the stack, or one taxonomy when you pass its UID.

```
Returns: Taxonomy. A new taxonomy object.
OverloadsTaxonomies(): This overload takes no parameters.Taxonomies(string uid)ValidationTaxonomies(uid) throws TaxonomyException at once if uid is null or empty, because the scoped object builds its request URL from the UID.The two overloads enable different methods, and calling a method from the other set throws TaxonomyException before any request:Fetch, Term, and Terms need a UID. Calling them on Taxonomies() throws.Listing taxonomies with Find needs no UID. Calling Find on Taxonomies(uid) throws.Errors from the API come from the Fetch or Find call that follows, not from Taxonomies.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Taxonomies builds the object and makes no request.Taxonomies() reaches every taxonomy. Call Find alone to list the published taxonomies, or chain a filter such as Above or Below before Find to return the entries tagged with matching terms.Taxonomies("<TAXONOMY_UID>") reaches one taxonomy. Call Fetch to read it, Terms to query its terms, or Term("<TERM_UID>") to reach one term.Taxonomy inherits from Query. See the Taxonomy class page for the methods on each object.ExampleBasic usage: list the published taxonomiesusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<JsonObject> taxonomies = await client.Taxonomies().Find<JsonObject>();
    foreach (JsonObject taxonomy in taxonomies)
    {
        Console.WriteLine($"{taxonomy["uid"]}: {taxonomy["name"]}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}One taxonomy: fetch it by UIDusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject taxonomy = await client.Taxonomies("<TAXONOMY_UID>").Fetch<JsonObject>();
    Console.WriteLine(taxonomy["name"]);
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID of the published taxonomy to read.

## ContentstackClient

Gets or sets the settings that should be used for deserialization.

Options the SDK uses to bind responses to your model classes.

## ContentstackClient | .NET Delivery SDK | Contentstack

The ContentstackClient class in the .NET Delivery SDK connects to one stack and environment, and returns the content type, asset, global field, taxonomy, and sync objects.

## Asset

An asset is one file uploaded to a stack, such as an image, a video or a PDF. Use the Asset class to

*   fetch one published asset by its UID
*   set the locale and response options for that fetch
*   read the file details, such as Url, FileName and FileSize, from the result

To list or filter many assets, use the [AssetLibrary](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/assetlibrary) class instead.

client.Asset(Uid) creates the object and sends no request. It takes the one parameter below:

Name

Type

Description

Uid

string

UID of the asset to fetch.

## AddParam

AddParam adds any query parameter to the Fetch request, for API options that have no method of their own.

```
Returns: Asset. The same asset, for chaining.
ValidationThere is no client-side validation of the parameter name or value.A null key throws ArgumentNullException.A key that this object already holds throws ArgumentException. This includes a key that another method on this class sets, such as include_fallback after the IncludeFallback method.environment passes AddParam, but the Fetch method then throws ArgumentException, because Fetch adds that parameter itself.A null value sends the parameter with an empty value.An invalid parameter surfaces as an AssetException when Fetch sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. AddParam stores the pair and makes no request. Fetch sends it as key=value.The SDK does not URL-encode the value. Encode a value that contains &, #, + or % yourself, for example with Uri.EscapeDataString.For example, the API returns the height and width of an image with include_dimension set to true (Get a single asset). The SDK reads them into the Dimension property.ExampleBasic usage: include the image dimensionsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>")
        .AddParam("include_dimension", "true")
        .Fetch();

    if (asset.Dimension != null)
    {
        Console.WriteLine($"{asset.Dimension["width"]} x {asset.Dimension["height"]}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the query parameter, for example include\_dimension.

Value of the query parameter, sent as written.

## AssetFields

AssetFields requests additional field groups for the asset, such as its visual markups.

```
Returns: Asset. The same asset, for chaining.
ValidationThere is no client-side validation of the field group names.A call with no arguments, null or an empty array changes nothing.A second call with at least one field group throws ArgumentException, because the SDK stores the asset_fields[] parameter once. Pass every group in one call.An invalid group name surfaces as an AssetException when Fetch sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. AssetFields adds one asset_fields[] query parameter per group and makes no request.With visual_markups, the API returns the hotspot and bounding-box annotations of the asset under the visual_markups key. An asset with no markups returns an empty array (Get a single asset).The SDK code comments also name user_defined_fields, embedded_metadata and ai_generated_metadata as accepted values.Asset has no property for these groups. Read each one with the Get method under the key of the same name.ExampleBasic usage: request the visual markups of an assetusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").AssetFields("visual_markups").Fetch();

    if (asset.Get("visual_markups") is List<object> markups)
    {
        Console.WriteLine($"{markups.Count} visual markups");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}All parameters: request several field groups in one callusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // A second AssetFields call on the same object throws, so pass every group here.
    Asset asset = await client.Asset("<ASSET_UID>")
        .AssetFields("visual_markups", "user_defined_fields")
        .Fetch();

    Console.WriteLine(asset.Get("user_defined_fields"));
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Field group names, for example visual\_markups. Adds each group to the response.

## Fetch

Fetch retrieves one published asset by the UID you passed to client.Asset.

```
Returns: Task<Asset>. The requested asset.
ValidationThere is no client-side validation of the UID. With a null or empty UID, Fetch requests /assets/ with no UID and throws AssetException.Fetch throws AssetException when the API rejects the request. StatusCode, ErrorCode, Message and Errors carry the details from the error response. For example, an asset UID that does not exist returns status 404 with error code 145.Fetch also throws AssetException when it cannot read the response, with the original error as InnerException.Fetch throws ArgumentException before it sends anything when you passed environment to the AddParam method, because Fetch adds that parameter itself.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorFetch sends one GET /assets/{asset_uid} request (Get a single asset). It adds the client's environment, then every option you chained, as query parameters.The request carries the client-level headers, the headers from SetHeader, and the branch header when the client sets Branch.Fetch returns a new Asset built from the asset object in the response. The object you called Fetch on does not change and keeps its options.The returned asset holds no client. Call Fetch on the object from client.Asset("<ASSET_UID>"), not on the result.The API returns the latest published version of the asset in the client's environment.ExampleBasic usage: fetch an asset by UIDusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").Fetch();
    Console.WriteLine($"{asset.FileName}: {asset.Url}");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Fetch with every response optionusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>")
        .SetLocale("<LOCALE>")
        .IncludeFallback()
        .IncludeMetadata()
        .IncludeBranch()
        .AssetFields("visual_markups")
        .Fetch();

    Console.WriteLine($"{asset.Title} (version {asset.Version})");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}Edge case: resize an image through its URLusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").Fetch();

    // The SDK has no image transformation methods. Add Image Delivery API
    // parameters to the URL yourself.
    string thumbnailUrl = $"{asset.Url}?width=300&format=webp";
    Console.WriteLine(thumbnailUrl);
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## Get

Get reads any field of the fetched asset by its key, including fields that have no property on Asset.

```
Returns: object. The value stored under the key.
ValidationThere is no client-side validation.A key that the response does not contain returns null. A null key also returns null.BehaviorClient-side only. Get reads the response that Fetch or FetchAll stored and makes no request.On the object from client.Asset("<ASSET_UID>"), which holds no response, Get returns null for every key.The list below maps each JSON value to the .NET type that Get returns:text returns stringa whole number returns int, or long when it does not fit, and other numbers return doubletrue and false return boolan object returns Dictionary<string, object>an array returns List<object>null returns nullThe indexer asset["<key>"] returns the same value.ExampleBasic usage: read fields that have no propertyusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").Fetch();

    Console.WriteLine(asset.Get("filename"));

    if (asset.Get("publish_details") is Dictionary<string, object> publishDetails)
    {
        foreach (KeyValuePair<string, object> detail in publishDetails)
        {
            Console.WriteLine($"{detail.Key}: {detail.Value}");
        }
    }

    // A key the response does not contain returns null.
    Console.WriteLine(asset.Get("no_such_field") == null);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Response field key, for example filename. Selects the value to return.

## GetCreateAt

GetCreateAt reads the creation time of the fetched asset.

```
Returns: DateTime. The asset's creation time.
ValidationThere is no client-side validation, and GetCreateAt does not throw.When the response has no created_at field, or its value is not a date, GetCreateAt returns DateTime.MinValue.BehaviorClient-side only. GetCreateAt reads the created_at field from the response that Fetch or FetchAll stored and makes no request.On the object from client.Asset("<ASSET_UID>"), which holds no response, GetCreateAt returns DateTime.MinValue.DateTime.Parse reads the value, so a UTC timestamp converts to the local time zone of the machine. Call ToUniversalTime() on the result to get UTC.ExampleBasic usage: read the created_at time of an assetusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").Fetch();

    DateTime value = asset.GetCreateAt();
    if (value == DateTime.MinValue)
    {
        Console.WriteLine("The response has no created_at value.");
    }
    else
    {
        Console.WriteLine($"Created: {value.ToUniversalTime():u}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## GetCreatedBy

GetCreatedBy reads the UID of the user who created the asset from the fetched asset.

```
Returns: string. The UID of the user who created the asset.
ValidationThere is no client-side validation.GetCreatedBy throws KeyNotFoundException when the response has no created_by field, because it reads the key without checking for it first.GetCreatedBy throws NullReferenceException when the created_by value is null.BehaviorClient-side only. GetCreatedBy reads the created_by field from the response that Fetch or FetchAll stored and makes no request.On the object from client.Asset("<ASSET_UID>"), which holds no response, GetCreatedBy throws KeyNotFoundException.The CreatedBy property holds the same value and returns null instead of throwing when the field is missing.ExampleBasic usage: read the created_by user of an assetusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").Fetch();
    Console.WriteLine(asset.GetCreatedBy());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
catch (KeyNotFoundException)
{
    // Thrown when the response has no created_by field
    Console.WriteLine("The response has no created_by value.");
}Edge case: read the value without risking an exceptionusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").Fetch();

    // Returns null when the field is missing, where GetCreatedBy throws.
    object user = asset.CreatedBy;
    Console.WriteLine(user ?? "not set");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## GetDeleteAt

GetDeleteAt reads the deleted\_at time from the fetched asset.

```
Returns: DateTime. The asset's deletion time.
ValidationThere is no client-side validation, and GetDeleteAt does not throw.When the response has no deleted_at field, or its value is not a date, GetDeleteAt returns DateTime.MinValue.BehaviorClient-side only. GetDeleteAt reads the deleted_at field from the response that Fetch or FetchAll stored and makes no request.On the object from client.Asset("<ASSET_UID>"), which holds no response, GetDeleteAt returns DateTime.MinValue.DateTime.Parse reads the value, so a UTC timestamp converts to the local time zone of the machine. Call ToUniversalTime() on the result to get UTC.Compare the result with DateTime.MinValue to tell whether the response carried a deleted_at value.ExampleBasic usage: read the deleted_at time of an assetusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").Fetch();

    DateTime value = asset.GetDeleteAt();
    if (value == DateTime.MinValue)
    {
        Console.WriteLine("The response has no deleted_at value.");
    }
    else
    {
        Console.WriteLine($"Deleted: {value.ToUniversalTime():u}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## GetDeletedBy

GetDeletedBy reads the deleted\_by user UID from the fetched asset.

```
Returns: string. The UID of the user who deleted the asset.
ValidationThere is no client-side validation.GetDeletedBy throws KeyNotFoundException when the response has no deleted_by field, because it reads the key without checking for it first.GetDeletedBy throws NullReferenceException when the deleted_by value is null.BehaviorClient-side only. GetDeletedBy reads the deleted_by field from the response that Fetch or FetchAll stored and makes no request.On the object from client.Asset("<ASSET_UID>"), which holds no response, GetDeletedBy throws KeyNotFoundException.Asset has no property for deleted_by. The Get method returns null instead of throwing when the field is missing.ExampleBasic usage: read the deleted_by user of an assetusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").Fetch();
    Console.WriteLine(asset.GetDeletedBy());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
catch (KeyNotFoundException)
{
    // Thrown when the response has no deleted_by field
    Console.WriteLine("The response has no deleted_by value.");
}Edge case: read the value without risking an exceptionusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").Fetch();

    // Returns null when the field is missing, where GetDeletedBy throws.
    object user = asset.Get("deleted_by");
    Console.WriteLine(user ?? "not set");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## GetUpdateAt

GetUpdateAt reads the last update time of the fetched asset.

```
Returns: DateTime. The asset's last update time.
ValidationThere is no client-side validation, and GetUpdateAt does not throw.When the response has no updated_at field, or its value is not a date, GetUpdateAt returns DateTime.MinValue.BehaviorClient-side only. GetUpdateAt reads the updated_at field from the response that Fetch or FetchAll stored and makes no request.On the object from client.Asset("<ASSET_UID>"), which holds no response, GetUpdateAt returns DateTime.MinValue.DateTime.Parse reads the value, so a UTC timestamp converts to the local time zone of the machine. Call ToUniversalTime() on the result to get UTC.ExampleBasic usage: read the updated_at time of an assetusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").Fetch();

    DateTime value = asset.GetUpdateAt();
    if (value == DateTime.MinValue)
    {
        Console.WriteLine("The response has no updated_at value.");
    }
    else
    {
        Console.WriteLine($"Last updated: {value.ToUniversalTime():u}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## GetUpdatedBy

GetUpdatedBy reads the UID of the user who last updated the asset from the fetched asset.

```
Returns: string. The UID of the user who last updated the asset.
ValidationThere is no client-side validation.GetUpdatedBy throws KeyNotFoundException when the response has no updated_by field, because it reads the key without checking for it first.GetUpdatedBy throws NullReferenceException when the updated_by value is null.BehaviorClient-side only. GetUpdatedBy reads the updated_by field from the response that Fetch or FetchAll stored and makes no request.On the object from client.Asset("<ASSET_UID>"), which holds no response, GetUpdatedBy throws KeyNotFoundException.The UpdatedBy property holds the same value and returns null instead of throwing when the field is missing.ExampleBasic usage: read the updated_by user of an assetusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").Fetch();
    Console.WriteLine(asset.GetUpdatedBy());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
catch (KeyNotFoundException)
{
    // Thrown when the response has no updated_by field
    Console.WriteLine("The response has no updated_by value.");
}Edge case: read the value without risking an exceptionusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").Fetch();

    // Returns null when the field is missing, where GetUpdatedBy throws.
    object user = asset.UpdatedBy;
    Console.WriteLine(user ?? "not set");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## IncludeBranch

IncludeBranch adds the \_branch key, which names the branch the asset belongs to, to the Fetch response.

```
Returns: Asset. The same asset, for chaining.
ValidationThere is no client-side validation.A second call on the same object throws ArgumentException, because the SDK stores each query parameter once.An invalid request surfaces as an AssetException when Fetch sends it.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeBranch adds include_branch=true to the request and makes no request itself.The API adds the _branch key with the unique ID of the branch (Get a single asset). Asset has no property for it. Read it with the Get method.IncludeBranch does not choose the branch. The Branch option of the client sends the branch header that selects it.ExampleBasic usage: read the branch of an assetusing System;
using Contentstack.Core;
using Contentstack.Core.Configuration;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient(new ContentstackOptions
{
    ApiKey = "<API_KEY>",
    DeliveryToken = "<DELIVERY_TOKEN>",
    Environment = "<ENVIRONMENT>",
    Branch = "<BRANCH>"
});

try
{
    Asset asset = await client.Asset("<ASSET_UID>").IncludeBranch().Fetch();
    Console.WriteLine(asset.Get("_branch"));
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeFallback

IncludeFallback returns the asset from the fallback locale when the requested locale has no published version.

```
Returns: Asset. The same asset, for chaining.
ValidationThere is no client-side validation.A second call on the same object throws ArgumentException, because the SDK stores each query parameter once.An invalid request surfaces as an AssetException when Fetch sends it.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeFallback adds include_fallback=true to the request and makes no request itself.The API returns the published asset details from the fallback locale when the specified locale does not contain published content (Get a single asset).Pair it with the SetLocale method, which names the locale that the fallback starts from.ExampleBasic usage: fetch an asset with locale fallbackusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>")
        .SetLocale("<LOCALE>")
        .IncludeFallback()
        .Fetch();

    Console.WriteLine(asset.Title);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeMetadata

IncludeMetadata adds the asset metadata, which extensions store on the asset, to the Fetch response.

```
Returns: Asset. The same asset, for chaining.
ValidationThere is no client-side validation.A second call on the same object throws AssetException, because the SDK stores each query parameter once. The original ArgumentException is the InnerException.An invalid request surfaces as an AssetException when Fetch sends it.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeMetadata adds include_metadata=true to the request and makes no request itself.The API returns the metadata under the _metadata key of the asset (Get a single asset).Asset has no property for _metadata. Read it with the Get method, which returns it as a Dictionary<string, object>.ExampleBasic usage: read the asset metadatausing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").IncludeMetadata().Fetch();

    // Metadata is keyed by the UID of the extension that added it.
    if (asset.Get("_metadata") is Dictionary<string, object> metadata)
    {
        foreach (KeyValuePair<string, object> item in metadata)
        {
            Console.WriteLine(item.Key);
        }
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## RemoveHeader

RemoveHeader removes a header that the [SetHeader](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient#contentstackclient-setheader) method added to this asset object.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation.A null key throws ArgumentNullException.A key that this object does not hold changes nothing.BehaviorClient-side only. RemoveHeader deletes the header from this asset object and makes no request.It does not remove a client-level header, such as api_key or access_token. When SetHeader overrode a client-level header, removing it makes Fetch send the client value again.RemoveHeader returns nothing, so you cannot chain after it. Call it as a separate statement.ExampleBasic usage: remove a header before the requestusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

Asset request = client.Asset("<ASSET_UID>");
request.SetHeader("x-request-id", "asset-sync-42");
request.RemoveHeader("x-request-id");

try
{
    // Fetch sends only the client-level headers.
    Asset asset = await request.Fetch();
    Console.WriteLine(asset.Url);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Header name. Identifies the header to remove.

## SetHeader

SetHeader adds an HTTP header to the Fetch request of this asset object only.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation of the name or value.A null key or a null value changes nothing. SetHeader ignores the call.A header name that HTTP does not allow, such as an empty string, passes SetHeader. Fetch then drops the header without an error.BehaviorClient-side only. SetHeader stores the header and makes no request.A second call with the same key replaces the value.Fetch sends these headers together with the client-level headers. When both name the same header, the value from SetHeader wins. Use this to send a different delivery token (access_token) for one asset.The header applies to this asset object only. Other assets and entries from the same client do not get it.SetHeader returns nothing, so you cannot chain after it. Call it as a separate statement.ExampleBasic usage: add a custom header to one requestusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

Asset request = client.Asset("<ASSET_UID>");
request.SetHeader("x-request-id", "asset-sync-42");

try
{
    Asset asset = await request.Fetch();
    Console.WriteLine(asset.Url);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Edge case: override the client's delivery token for one assetusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

Asset request = client.Asset("<ASSET_UID>");

// This value replaces the client-level access_token header for this request only.
request.SetHeader("access_token", "<DELIVERY_TOKEN>");

try
{
    Asset asset = await request.Fetch();
    Console.WriteLine(asset.FileName);
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Header name. Identifies the header to send.

Header value. Sent with the header name.

## SetLocale

SetLocale sets the locale that Fetch requests the asset in.

```
Returns: Asset. The same asset, for chaining.
ValidationThere is no client-side validation of the locale code.A null or empty locale changes nothing. SetLocale ignores it and keeps any locale set before.An invalid value surfaces as an AssetException when Fetch sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. SetLocale stores the locale query parameter and makes no request.A second call replaces the locale. Unlike the other options on this class, it does not throw.The localized title arrives in the Title property of the asset that Fetch returns.Chain the IncludeFallback method to get the fallback locale version when the asset has no published localization in locale (Get a single asset).ExampleBasic usage: fetch an asset in a localeusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>").SetLocale("<LOCALE>").Fetch();
    Console.WriteLine(asset.Title);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Edge case: fall back when the locale has no published versionusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Asset asset = await client.Asset("<ASSET_UID>")
        .SetLocale("<LOCALE>")
        .IncludeFallback()
        .Fetch();

    // With IncludeFallback, the title can come from the fallback locale.
    Console.WriteLine(asset.Title);
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Locale code, for example en-us. Selects the asset localization.

## Asset

Asset uid

Asset URL

File Name for asset

File size for asset

Tags assign to asset

UID of the asset. On a request object, the UID you passed.

Absolute URL of the file (url).

Original name of the file (filename).

Size of the file in bytes, as text (file\_size).

MIME type of the file (content\_type), for example image/png.

Title of the asset in the requested locale (title).

Description of the asset (description).

Tags on the asset (tags). Each item is a JsonElement.

Image height and width (dimension). Each value is a JsonElement.

Publish environment, locale and time (publish\_details). Each value is a JsonElement.

Version number of the asset (\_version).

Whether the item is a folder (is\_dir).

UID of the folder that holds the asset (parent\_uid).

UID of the user who created the asset (created\_by).

UID of the user who last updated the asset (updated\_by).

Content type UID that the response gives the asset (\_content\_type\_uid).

Client that sends Fetch. null on an asset that Fetch returned.

Any response field by its key, for example asset\["filename"\]. Returns null for a missing key.

## Asset | .NET Delivery SDK | Contentstack

The Asset class in the .NET Delivery SDK fetches one published file by its UID and exposes its URL, file name, size, title and other details.

## AssetLibrary

AssetLibrary builds a request for the published assets in a stack. Use this class to

*   list assets, one page at a time
*   filter, sort and shape the list before you send the request
*   get the number of matching assets without the assets themselves

To fetch one asset by its UID, use the [Asset](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/asset) class instead.

client.AssetLibrary() creates the object. It takes no arguments and sends no request. Chain the options, then call FetchAll for the assets or Count for the number.

## AddParam

AddParam adds any query parameter to the request, for API options that have no method of their own.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation of the parameter name or value.A null key throws ArgumentNullException.A key that this object already holds throws ArgumentException. This includes a key that another method on this class sets, such as limit after the Limit method.environment passes AddParam, but FetchAll and Count then throw ArgumentException, because they add that parameter themselves.A null value sends the parameter with an empty value.An invalid parameter surfaces as an AssetException when FetchAll or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. AddParam stores the pair and makes no request. The request carries it as key=value.The SDK does not URL-encode the value. Encode a value that contains &, #, + or % yourself, for example with Uri.EscapeDataString.For example, the API returns the height and width of each image with include_dimension set to true (Get all assets). The SDK reads them into the Dimension property of each asset.ExampleBasic usage: include the image dimensionsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary()
        .AddParam("include_dimension", "true")
        .FetchAll();

    foreach (Asset asset in assets)
    {
        if (asset.Dimension != null)
        {
            Console.WriteLine($"{asset.FileName}: {asset.Dimension["width"]} x {asset.Dimension["height"]}");
        }
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the query parameter, for example include\_dimension.

Value of the query parameter, sent as written.

## AssetFields

AssetFields requests additional field groups for each asset, such as its visual markups.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation of the field group names.A call with no arguments, null or an empty array changes nothing.A second call with at least one field group throws ArgumentException, because the SDK stores the asset_fields[] parameter once. Pass every group in one call.An invalid group name surfaces as an AssetException when FetchAll sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. AssetFields adds one asset_fields[] query parameter per group and makes no request.With visual_markups, the API returns the hotspot and bounding-box annotations of each asset under the visual_markups key. An asset with no markups returns an empty array (Get all assets).The SDK code comments also name user_defined_fields, embedded_metadata and ai_generated_metadata as accepted values.Asset has no property for these groups. Read each one with the Asset Get method under the key of the same name.ExampleBasic usage: request visual markups for every assetusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary()
        .AssetFields("visual_markups", "user_defined_fields")
        .FetchAll();

    foreach (Asset asset in assets)
    {
        int markupCount = asset.Get("visual_markups") is List<object> markups ? markups.Count : 0;
        Console.WriteLine($"{asset.FileName}: {markupCount} visual markups");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Field group names, for example visual\_markups. Adds each group to the response.

## Count

Count sends the request and returns only the number of published assets that match the options on the instance.

```
Returns: Task<JsonObject>. The response body as a JSON object.
ValidationThere is no client-side validation.Count throws AssetException when the API rejects the request. StatusCode, ErrorCode, Message and Errors carry the details from the error response.Count also throws AssetException when it cannot send the request or read the response body, with the original error as InnerException.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorCount adds count=true to the instance, then sends one GET /assets request with every option on the instance.With count=true, the API returns only the count, not the assets (Count).Filters such as Where and Tags apply, so the count covers only the matching assets.Count returns the whole response body as a JsonObject (System.Text.Json.Nodes). The SDK does not extract the number.To get the assets and the total in one request, use the IncludeCount method with FetchAll instead.ExampleBasic usage: count the assets in a stackusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject result = await client.AssetLibrary().Count();
    Console.WriteLine(result.ToJsonString());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Edge case: count first, then list, with separate instancesusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // Count leaves count=true on its instance, so list with a new one.
    JsonObject total = await client.AssetLibrary().Where("content_type", "image/png").Count();
    ContentstackCollection<Asset> page = await client.AssetLibrary().Where("content_type", "image/png").FetchAll();

    Console.WriteLine(total.ToJsonString());
    foreach (Asset asset in page)
    {
        Console.WriteLine(asset.FileName);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## Except

Except sends the list of top-level fields to leave out of each asset in the response.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation of the field UIDs.null or an empty array changes nothing.A second call with at least one field throws AssetException, because the SDK stores each query parameter once. Pass every field in one call.An invalid value surfaces as an AssetException when FetchAll sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Except adds one except[BASE][] query parameter per field and makes no request.The Exclude Operator section of the API reference documents except[BASE][] for entries only, and the Get all assets request does not list it. Check the response before you rely on it for assets.Properties for fields the response leaves out keep their default values, for example null.ExampleBasic usage: leave out the description and tagsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary()
        .Except(new string[] { "description", "tags" })
        .FetchAll();

    foreach (Asset asset in assets)
    {
        Console.WriteLine($"{asset.FileName}: {asset.Url}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Field UIDs to leave out, for example description.

## FetchAll

FetchAll sends the request and returns one page of the published assets that match the options on the instance.

```
Returns: Task<ContentstackCollection<Asset>>. The matching assets.
ValidationThere is no client-side validation.FetchAll throws AssetException when the API rejects the request. StatusCode, ErrorCode, Message and Errors carry the details from the error response.FetchAll also throws AssetException when it cannot send the request or read the response body, with the original error as InnerException.FetchAll throws ArgumentException before it sends anything when you passed environment to the AddParam method, because FetchAll adds that parameter itself.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorFetchAll sends one GET /assets request (Get all assets). It adds the client's environment, then every option on the instance, as query parameters.The result holds one page. Without Limit, the API returns the first 100 assets (Pagination). The SDK does not request further pages.Items holds the assets, and the collection itself is enumerable. When nothing matches, Items is empty and no exception occurs.Count holds the total number of matching assets only after the IncludeCount method. Otherwise it is 0.Skip and Limit on the result stay 0, because the API does not return them. See the ContentstackCollection class.Each asset carries the full response data, so its getters such as GetCreateAt work.FetchAll does not clear the options, so a second call on the same instance sends the same request. Do not call FetchAll on an instance that the Count method already used, because the count flag stays on the instance.ExampleBasic usage: list the assets in a stackusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary().FetchAll();
    foreach (Asset asset in assets)
    {
        Console.WriteLine($"{asset.Uid}: {asset.FileName}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Edge case: read every asset, one page at a timeusing System;
using System.Collections.Generic;
using System.Linq;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

const int pageSize = 100;
List<Asset> all = new List<Asset>();

try
{
    int skip = 0;
    while (true)
    {
        // Options stay on an instance, so build a new one for each page.
        ContentstackCollection<Asset> page = await client.AssetLibrary()
            .Skip(skip)
            .Limit(pageSize)
            .FetchAll();

        all.AddRange(page.Items);
        if (page.Items.Count() < pageSize)
        {
            break;
        }
        skip += pageSize;
    }
    Console.WriteLine($"Read {all.Count} assets");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## IncludeBranch

IncludeBranch adds the \_branch key, which names the branch each asset belongs to, to the FetchAll response.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation.A second call on the same instance throws AssetException, because the SDK stores each query parameter once. The original ArgumentException is the InnerException.An invalid request surfaces as an AssetException when FetchAll sends it.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeBranch adds include_branch=true to the request and makes no request itself.The API adds the _branch key with the unique ID of the branch (Get all assets). Asset has no property for it. Read it with the Asset Get method.IncludeBranch does not choose the branch. The Branch option of the client sends the branch header that selects it.ExampleBasic usage: list assets from a branchusing System;
using Contentstack.Core;
using Contentstack.Core.Configuration;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient(new ContentstackOptions
{
    ApiKey = "<API_KEY>",
    DeliveryToken = "<DELIVERY_TOKEN>",
    Environment = "<ENVIRONMENT>",
    Branch = "<BRANCH>"
});

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary().IncludeBranch().FetchAll();
    foreach (Asset asset in assets)
    {
        Console.WriteLine($"{asset.FileName}: {asset.Get("_branch")}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeCount

IncludeCount adds the total number of matching assets to the FetchAll result.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation.A second call on the same instance throws ArgumentException, because the SDK stores each query parameter once.An invalid request surfaces as an AssetException when FetchAll sends it.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeCount adds include_count=true to the request and makes no request itself.The API returns the assets and their total count (Count). The SDK puts the total in the Count property of the result. Without IncludeCount, Count is 0.The total covers every matching asset, not only the current page. Compare it with Skip plus the page size to decide whether more pages remain.IncludeCount returns nothing, so you cannot chain after it. Call it as a separate statement.To get only the number, without the assets, use the Count method.ExampleBasic usage: list assets with the total countusing System;
using System.Linq;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

AssetLibrary library = client.AssetLibrary().Limit(10);
library.IncludeCount();

try
{
    ContentstackCollection<Asset> assets = await library.FetchAll();
    Console.WriteLine($"Showing {assets.Items.Count()} of {assets.Count} assets");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeFallback

IncludeFallback returns each asset from the fallback locale when the requested locale has no published version.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation.A second call on the same instance throws AssetException, because the SDK stores each query parameter once. The original ArgumentException is the InnerException.An invalid request surfaces as an AssetException when FetchAll or Count sends it.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeFallback adds include_fallback=true to the request and makes no request itself.The API includes the published asset details from the fallback locale when the specified locale does not contain published content (Get all assets).Pair it with the SetLocale method, which names the locale that the fallback starts from.ExampleBasic usage: list assets with locale fallbackusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary()
        .SetLocale("<LOCALE>")
        .IncludeFallback()
        .FetchAll();

    foreach (Asset asset in assets)
    {
        Console.WriteLine(asset.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeMetadata

IncludeMetadata adds the metadata of each asset, which extensions store on it, to the FetchAll response.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation.A second call on the same instance throws AssetException, because the SDK stores each query parameter once. The original ArgumentException is the InnerException.An invalid request surfaces as an AssetException when FetchAll sends it.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeMetadata adds include_metadata=true to the request and makes no request itself.The API returns the metadata of each asset under its _metadata key (Get all assets).Asset has no property for _metadata. Read it with the Asset Get method, which returns it as a Dictionary<string, object>.ExampleBasic usage: read the metadata of each assetusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary().IncludeMetadata().FetchAll();

    foreach (Asset asset in assets)
    {
        // Metadata is keyed by the UID of the extension that added it.
        int extensions = asset.Get("_metadata") is Dictionary<string, object> metadata ? metadata.Count : 0;
        Console.WriteLine($"{asset.FileName}: metadata from {extensions} extensions");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeRelativeUrls

IncludeRelativeUrls adds the relative\_urls=true flag to the FetchAll request.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation.A second call on the same instance throws ArgumentException, because the SDK stores each query parameter once.An invalid request surfaces as an AssetException when FetchAll sends it.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeRelativeUrls adds relative_urls=true to the request and makes no request itself.The SDK reads whatever the API returns in url into the Url property of each asset, without changing it.The Get all assets request in the API reference does not list a relative_urls parameter. Check the Url values before you rely on the format.IncludeRelativeUrls returns nothing, so you cannot chain after it. Call it as a separate statement.ExampleBasic usage: list assets with the relative URL flagusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

AssetLibrary library = client.AssetLibrary();
library.IncludeRelativeUrls();

try
{
    ContentstackCollection<Asset> assets = await library.FetchAll();
    foreach (Asset asset in assets)
    {
        Console.WriteLine(asset.Url);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## Limit

Limit caps the number of assets that FetchAll returns.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation. Limit accepts zero or a negative number and sends it as written.The API accepts positive integers only. With 0 or a non-numeric value, it returns the default number of assets rather than all of them (Limit).A second call on the same instance throws AssetException, because the SDK stores each query parameter once. The original ArgumentException is the InnerException.An invalid value surfaces as an AssetException when FetchAll sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Limit adds the limit query parameter and makes no request.Without Limit, the API returns the first 100 assets (Pagination).Combine it with the Skip method to read one page at a time. The Limit property of the result stays 0, so track the value you sent.ExampleBasic usage: return the first 5 assetsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary().Limit(5).FetchAll();
    foreach (Asset asset in assets)
    {
        Console.WriteLine(asset.FileName);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Maximum number of assets to return. Sets the page size.

## Only

Only sends the list of top-level fields to keep in each asset of the response.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation of the field UIDs.null or an empty array changes nothing.A second call with at least one field throws AssetException, because the SDK stores each query parameter once. Pass every field in one call.An invalid value surfaces as an AssetException when FetchAll sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Only adds one only[BASE][] query parameter per field and makes no request.The Only Operator section of the API reference documents only[BASE][] for entries only, and the Get all assets request does not list it. Check the response before you rely on it for assets.Properties for fields the response leaves out keep their default values, for example null or an empty Url.ExampleBasic usage: keep only the title and URLusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary()
        .Only(new string[] { "title", "url" })
        .FetchAll();

    foreach (Asset asset in assets)
    {
        Console.WriteLine($"{asset.Title}: {asset.Url}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Field UIDs to keep, for example title and url.

## Query

Query adds a JSON query to the request, for conditions that need an operator such as $regex or $lt.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation of the query. The SDK sends it as written.null on the first call sends an empty query parameter. null after an earlier Where or Query call changes nothing.Query wraps any failure while it stores the conditions in an AssetException.An invalid query surfaces as an AssetException when FetchAll or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Query stores the object as the query parameter and makes no request.Query and the Where method share one query parameter. A later call merges into it:a key that is new adds a conditiontwo objects under the same key merge key by keytwo arrays under the same key combine, and the SDK skips items already presentany other value under the same key replaces the earlier oneThe first object you pass becomes the stored query, and later Where or Query calls edit it in place. Do not reuse that JsonObject for another request.Not every operator works for assets. For example, Less Than, Search by Regex and AND Operator work for assets, and $exists works for entries only.The SDK does not URL-encode the query, so &, # or + in a value changes the meaning of the request URL.ExampleBasic usage: match file names with a regular expressionusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

JsonObject query = new JsonObject
{
    ["filename"] = new JsonObject { ["$regex"] = "^banner" }
};

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary().Query(query).FetchAll();
    foreach (Asset asset in assets)
    {
        Console.WriteLine(asset.FileName);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Edge case: combine two conditions with $andusing System;
using System.Linq;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

JsonObject query = new JsonObject
{
    ["$and"] = new JsonArray
    {
        new JsonObject { ["content_type"] = "image/png" },
        new JsonObject { ["title"] = new JsonObject { ["$regex"] = "banner" } }
    }
};

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary().Query(query).FetchAll();
    Console.WriteLine($"Matched {assets.Items.Count()} assets on this page");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Query conditions in Content Delivery API syntax. Filters the assets.

## RemoveHeader

RemoveHeader removes a header that the [SetHeaderForKey](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/assetlibrary#assetlibrary-setheaderforkey) method added to this instance.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation.A null key throws ArgumentNullException.A key that this instance does not hold changes nothing.BehaviorClient-side only. RemoveHeader deletes the header from this instance and makes no request.It does not remove a client-level header, such as api_key or access_token. When SetHeaderForKey overrode a client-level header, removing it makes the request send the client value again.ExampleBasic usage: remove a header before the requestusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // FetchAll sends only the client-level headers.
    ContentstackCollection<Asset> assets = await client.AssetLibrary()
        .SetHeaderForKey("x-request-id", "asset-sync-42")
        .RemoveHeader("x-request-id")
        .FetchAll();

    foreach (Asset asset in assets)
    {
        Console.WriteLine(asset.FileName);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Header name. Identifies the header to remove.

## SetHeaderForKey

SetHeaderForKey adds an HTTP header to the requests of this asset library instance only.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation of the name or value.A null key or a null value changes nothing. SetHeaderForKey ignores the call.A header name that HTTP does not allow, such as an empty string, passes SetHeaderForKey. FetchAll and Count then drop the header without an error.BehaviorClient-side only. SetHeaderForKey stores the header and makes no request.A second call with the same key replaces the value.FetchAll and Count send these headers together with the client-level headers. When both name the same header, the value from SetHeaderForKey wins.The header applies to this instance only. Other asset libraries, assets and entries from the same client do not get it.ExampleBasic usage: add a custom header to one requestusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary()
        .SetHeaderForKey("x-request-id", "asset-sync-42")
        .FetchAll();

    foreach (Asset asset in assets)
    {
        Console.WriteLine(asset.FileName);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Header name. Identifies the header to send.

Header value. Sent with the header name.

## SetLocale

SetLocale sets the locale that FetchAll lists the assets in.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation of the locale code.A null or empty Locale replaces any locale set before and sends the locale parameter with an empty value.An invalid value surfaces as an AssetException when FetchAll or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. SetLocale stores the locale query parameter and makes no request.A second call replaces the locale. Unlike most options on this class, it does not throw.The localized title of each asset arrives in its Title property.Chain the IncludeFallback method to get the fallback locale version of assets that have no published localization in Locale (Get all assets).ExampleBasic usage: list assets in a locale with fallbackusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary()
        .SetLocale("<LOCALE>")
        .IncludeFallback()
        .FetchAll();

    foreach (Asset asset in assets)
    {
        Console.WriteLine(asset.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Locale code, for example en-us. Selects the asset localizations.

## Skip

Skip skips a number of assets at the start of the result, for pagination.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation. Skip accepts a negative number and sends it as written.A second call on the same instance throws AssetException, because the SDK stores each query parameter once. The original ArgumentException is the InnerException.An invalid value surfaces as an AssetException when FetchAll sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Skip adds the skip query parameter and makes no request.The skip parameter works for both entries and assets (Skip).Without Skip, the result starts at the first asset.Combine it with the Limit method to read one page at a time. The Skip property of the result stays 0, so track the value you sent.ExampleBasic usage: read the second page of 20 assetsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> page = await client.AssetLibrary()
        .Skip(20)
        .Limit(20)
        .FetchAll();

    foreach (Asset asset in page)
    {
        Console.WriteLine(asset.FileName);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Number of assets to skip. Sets the start of the page.

## SortWithKeyAndOrderBy

SortWithKeyAndOrderBy sorts the assets by the value of one field, in ascending or descending order.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation of the field UID.A second call with the same direction throws ArgumentException, because the SDK stores each query parameter once.A null key sends the sort parameter with an empty value.An invalid field surfaces as an AssetException when FetchAll sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. SortWithKeyAndOrderBy stores the sort parameter and makes no request.The asc and desc parameters work for both entries and assets (Order by asc, Order by desc).One call in each direction sends both asc and desc in the same request. Sort by one field per request.SortWithKeyAndOrderBy returns nothing, so you cannot chain after it. Call it as a separate statement.ExampleBasic usage: newest assets firstusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

AssetLibrary library = client.AssetLibrary();
library.SortWithKeyAndOrderBy("created_at", OrderBy.OrderByDescending);

try
{
    ContentstackCollection<Asset> assets = await library.FetchAll();
    foreach (Asset asset in assets)
    {
        Console.WriteLine($"{asset.GetCreateAt():u} {asset.FileName}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}All parameters: file names in ascending orderusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

AssetLibrary library = client.AssetLibrary().Limit(20);
library.SortWithKeyAndOrderBy("filename", OrderBy.OrderByAscending);

try
{
    ContentstackCollection<Asset> assets = await library.FetchAll();
    foreach (Asset asset in assets)
    {
        Console.WriteLine(asset.FileName);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Asset field UID to sort by, for example created\_at.

Sort direction. Sets ascending or descending order.

## Tags

Tags adds tags to the request, to list the assets that carry them.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation of the tag names.null or an empty array changes nothing, and any tags set before stay.An invalid value surfaces as an AssetException when FetchAll or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Tags stores the array and makes no request. The request carries one tags query parameter per tag, for example tags=banner&tags=hero.A second call replaces the tags from the first call. It does not add to them.The Get all assets request in the API reference does not list a tags parameter. Check the response before you rely on it.ExampleBasic usage: list assets tagged banner or herousing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary()
        .Tags(new string[] { "banner", "hero" })
        .FetchAll();

    foreach (Asset asset in assets)
    {
        Console.WriteLine($"{asset.FileName}: {string.Join(", ", asset.Tags ?? new object[0])}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Tag names, for example banner. Sent as the tag filter.

## Where

Where matches assets whose field equals a text value.

```
Returns: AssetLibrary. The same asset library, for chaining.
ValidationThere is no client-side validation of the field or the value.A null or empty key changes nothing. Where ignores the call.A null value stores a JSON null condition for the field.If storing the condition fails, Where throws a plain System.Exception, not a ContentstackException, with the original error as InnerException. A catch (ContentstackException) block does not catch it.An invalid condition surfaces as an AssetException when FetchAll or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Where writes {"<key>": "<value>"} into the query parameter and makes no request.The equals condition works for both entries and assets (Equals Operator).Calls on different fields combine, and an asset must match all of them. A second call on the same field replaces the first value.Where and the Query method share one query parameter, so their conditions combine.Where compares text only. For numbers, booleans or operators such as $regex, use the Query method.The SDK does not URL-encode the condition, so &, # or + in a value changes the meaning of the request URL.ExampleBasic usage: find assets by file nameusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Asset> assets = await client.AssetLibrary()
        .Where("filename", "banner.png")
        .FetchAll();

    foreach (Asset asset in assets)
    {
        Console.WriteLine($"{asset.Uid}: {asset.Url}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Edge case: two conditions that must both matchusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // The query parameter holds both conditions: content_type and title.
    ContentstackCollection<Asset> assets = await client.AssetLibrary()
        .Where("content_type", "image/png")
        .Where("title", "Home banner")
        .FetchAll();

    foreach (Asset asset in assets)
    {
        Console.WriteLine(asset.FileName);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Asset field UID, for example filename. Names the field to compare.

Value the field must equal. Filters the assets by it.

## AssetLibrary

Client that sends the request.

## AssetLibrary | .NET Delivery SDK | Contentstack

The AssetLibrary class in the .NET Delivery SDK lists the published assets in a stack, with filters, sorting, pagination and a count-only request.

## ContentType

ContentType represents one content type of a stack. Use this class to

*   fetch the schema of the content type
*   create an [Entry](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/entry) object to fetch one entry
*   create a [Query](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/query) object to fetch a list of entries

The class has no public constructor. Create an instance with the [ContentType](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient#contentstackclient-contenttype) method of ContentstackClient, which takes the parameter below:

Name

Type

Description

contentTypeName

string

UID of the content type.

## Entry

Entry creates an entry object for one entry of this content type.

```
Returns: Entry. A new entry object.
ValidationThere is no client-side validation. Entry accepts an empty string or null and raises no error.With an empty or null UID, the Fetch call that follows throws EntryException, because the SDK then requests the entry list path instead of one entry.The API rejects an unknown UID, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Entry makes no request. Call Fetch on the object it returns.Each call returns a new object, so options chained on one entry object do not affect another.The new object takes the headers of this content type at the time of the call.A non-empty UID also becomes the client's current entry UID, which the LivePreviewQueryAsync method uses when its query names no entry.See the Entry class for every option and getter.ExampleBasic usage: create an entry object and fetch itusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

Entry request = client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>");

try
{
    Entry entry = await request.Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

UID of the entry to fetch.

## Fetch

Fetch retrieves the schema of the content type from the Content Delivery API.

```
Returns: Task<JsonObject>. The requested content type.
ValidationThere is no client-side validation of the content type UID or of param.Throws ContentTypeException, a subclass of ContentstackException, when the API rejects the request, for example for an unknown content type UID or an invalid delivery token. Message, ErrorCode, StatusCode, and Errors carry the error details from the API.Throws ContentTypeException when the response holds no content_type object. An empty content type UID causes this.Throws ContentTypeException if param holds the key environment, because the SDK already sends the client's environment under that name.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorFetch sends one GET /content_types/{content_type_uid} request with the client's environment and each param entry as a query parameter. See Get a single content type in the Content Delivery API reference.It returns the content_type object of the response, not the whole response body. Read the schema from its schema key.The SDK writes each param value with ToString(), so true goes out as True. Pass the string "true" for a flag.Useful parameters include include_branch, which adds the _branch key, and include_global_field_schema, which adds the schema of each Global field to the content type schema. See the tip in Get all content types.Each call sends a new request. The SDK does not cache the schema.ExampleBasic usage: fetch a content type schemausing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject contentType = await client.ContentType("<CONTENT_TYPE_UID>").Fetch();
    Console.WriteLine(contentType["title"]);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}All parameters: include Global field schemas and the branchusing System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

Dictionary<string, object> param = new Dictionary<string, object>
{
    { "include_global_field_schema", "true" },
    { "include_branch", "true" }
};

try
{
    JsonObject contentType = await client.ContentType("<CONTENT_TYPE_UID>").Fetch(param);
    Console.WriteLine(contentType["_branch"]);
    Console.WriteLine(contentType["schema"]?.AsArray().Count);
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Extra query parameters for the request.

## Query

Query creates a query object across the entries of this content type.

```
Returns: Query. A new query object.
ValidationThere is no client-side validation.An unknown content type UID fails when the query sends its request: Find throws QueryFilterException.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Query makes no request. Chain filters on the object it returns, then call Find or FindOne.Each call returns a new object, so filters on one query do not affect another.The new object takes the headers of this content type at the time of the call.See the Query class for every filter and option.ExampleBasic usage: list the first ten entriesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Query query = client.ContentType("<CONTENT_TYPE_UID>").Query();
    ContentstackCollection<Entry> entries = await query.Limit(10).Find<Entry>();

    foreach (Entry entry in entries)
        Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## RemoveHeader

RemoveHeader deletes a header from the headers that SetHeader writes on this content type.

```
Returns: void. This method returns nothing.
ValidationThrows ArgumentNullException if key is null.A name that the content type does not hold leaves it unchanged and raises no error.BehaviorClient-side only. RemoveHeader makes no request.It removes only headers set with SetHeader on this content type. Client headers, such as api_key and access_token, stay in place.Entry and Query objects created before the call keep the header. Objects created after it do not have it.ExampleBasic usage: remove a header before creating an entryusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

ContentType contentType = client.ContentType("<CONTENT_TYPE_UID>");
contentType.SetHeader("branch", "<BRANCH>");
contentType.RemoveHeader("branch");

try
{
    // This entry has no content type branch header.
    Entry entry = await contentType.Entry("<ENTRY_UID>").Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the header to remove.

## SetHeader

SetHeader adds a request header for this content type and the entries and queries you create from it afterwards.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation of the header name or value.SetHeader ignores the call when key or value is null, and raises no error.A request skips, without an error, a header that .NET does not let a request set directly, such as Content-Type or User-Agent.BehaviorClient-side only. SetHeader stores the header and makes no request.The header goes out with Fetch on this content type, and with every Entry or Query object you create from it after the call. Objects created earlier keep the headers they had.A second call with the same key replaces the value.A content type header replaces a client header of the same name. A header set on an entry or a query replaces it in turn.ExampleBasic usage: send a branch header for one content typeusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

ContentType contentType = client.ContentType("<CONTENT_TYPE_UID>");
contentType.SetHeader("branch", "<BRANCH>");

try
{
    // Create the entry after SetHeader so that it takes the header.
    Entry entry = await contentType.Entry("<ENTRY_UID>").Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the header.

Value of the header.

## ContentType

Content type uid

## ContentType | .NET Delivery SDK | Contentstack

The ContentType class in the .NET Delivery SDK fetches a content type schema and creates the Entry and Query objects that read its entries.

## Entry

Entry represents one entry of a content type. Use this class to

*   fetch a single published entry by its UID
*   shape the response with references, field lists, a locale, and entry variants
*   read fields and system values from the entry that Fetch returns

The class has no public constructor. Create an instance with the [Entry](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contenttype#contenttype-entry) method of ContentType, which takes the parameter below:

Name

Type

Description

entryUid

string

UID of the entry to fetch.

## AddParam

AddParam adds a query parameter of your choice to the Fetch request.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation of the name or the value.Throws EntryException at once if key is null, or if this entry already holds a parameter named key. The Include methods, SetLocale, Only, and Except each hold their own key, so AddParam("locale", ...) after SetLocale throws.A null value sends the parameter with an empty value.Fetch throws EntryException if key is environment, because the SDK already sends the client's environment under that name.The API rejects an invalid parameter, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. AddParam stores key=value for the query string of the next Fetch call and makes no request.Use it for a Content Delivery API parameter that has no method of its own on Entry, for example include_all and include_all_depth from Include all references.The SDK writes the name and value into the query string as given, without URL encoding. Encode a value that contains &, =, #, or a space with Uri.EscapeDataString before you pass it.See the AddParam method of Query for the same option on a list of entries.ExampleBasic usage: include every referenced entryusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .AddParam("include_all", "true")
        .Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}All parameters: include references two levels deepusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .AddParam("include_all", "true")
        .AddParam("include_all_depth", "2")
        .Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}Edge case: a parameter name that another method already setusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

Entry entry = client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").IncludeFallback();

try
{
    entry.AddParam("include_fallback", "true");
}
catch (EntryException e)
{
    // Thrown at once, because IncludeFallback already set include_fallback
    Console.WriteLine(e.Message);
}
```

Name of the query parameter to send.

Value of the query parameter.

## AssetFields

AssetFields requests extra field groups for the assets that the entry references.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation of the field group names.A null or empty fields leaves the request unchanged.Throws ArgumentException at once on a second call on the same entry. Pass every field group in one call.The API rejects an invalid value, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. AssetFields stores each value as an asset_fields[] query parameter for the next Fetch call and makes no request.fields is a params array, so you can pass the names as separate arguments or as one string[].visual_markups returns the hotspot and bounding-box annotations of each embedded asset under the visual_markups key. See Get a single entry for the field groups the API supports.The SDK passes every value through as given.See the AssetFields method of Query for the same option on a list of entries.ExampleBasic usage: request the visual markups of embedded assetsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .AssetFields("visual_markups")
        .Fetch<Entry>();
    Console.WriteLine(entry.ToJson());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}All parameters: pass the field groups as one arrayusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

string[] fieldGroups = new string[] { "visual_markups" };

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .AssetFields(fieldGroups)
        .Fetch<Entry>();
    Console.WriteLine(entry.ToJson());
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Asset field groups to add to the response.

## Except

Except leaves the named fields out of the fetched entry and returns every other field.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation of the field UIDs.A null or empty array leaves the request unchanged.A second Except call on the same entry has no effect and raises no error. Pass every field UID in one array.The API rejects an invalid value, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Except stores each UID as an except[BASE][] query parameter for the next Fetch call and makes no request.BASE refers to the top-level fields of the entry. Name a field inside a Group or Modular Blocks field with dot notation, for example seo.description. See Exclude operator in the Content Delivery API reference.To leave out fields of referenced entries, use the IncludeExceptReference method instead.Use the Only method to name the fields to keep instead of the fields to drop.See the Except method of Query for the same option on a list of entries.ExampleBasic usage: drop two fields from the responseusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .Except(new string[] { "body", "seo" })
        .Fetch<Entry>();
    Console.WriteLine(entry.Get("body") == null);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Edge case: drop a field inside a Group fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // Dot notation names the description field inside the seo group.
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .Except(new string[] { "seo.description" })
        .Fetch<Entry>();
    Console.WriteLine(entry.Get("seo"));
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UIDs of the fields to leave out.

## Fetch

Fetch retrieves the entry from the Content Delivery API and returns it as an object of type T.

```
Returns: Task<T>. The requested entry.
ValidationThere is no client-side validation of the content type UID, the entry UID, or the chained options.Throws EntryException, a subclass of ContentstackException, when the API rejects the request, for example for an unknown entry UID or an invalid delivery token. Message, ErrorCode, StatusCode, and Errors carry the error details from the API.Throws EntryException with ErrorCode 0 when the response holds no entry object. An empty or null entry UID causes this, because the SDK then requests the entry list path instead of one entry.Throws LivePreviewException when live preview is on for this content type and the live preview configuration holds neither a preview token nor a management token.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorFetch sends one GET /content_types/{content_type_uid}/entries/{entry_uid} request. The query string carries the client's environment and every option you chained before the call. See Get a single entry in the Content Delivery API reference.The API returns the latest published version of the entry.The type argument decides what you get back:Fetch<Entry>() returns a new Entry that holds the response, so the getters such as GetTitle and Get work on it.Fetch<T>() with your own class maps the entry object of the response onto it. Property names match JSON keys without regard to case.Fetch does not fill the object you call it on. That object keeps its options, so a second Fetch call sends the same request again.The request carries the client headers, the content type headers, and the headers set on this entry. A header set on the entry replaces one of the same name from the content type or the client.The client's Branch option sends a branch header, unless Variant or SetHeader sets a branch header on this entry.When live preview is on for this content type, Fetch adds the live_preview query parameter and sends the preview or management token. See LivePreviewConfig.A reference field holds only the UIDs of the referenced entries unless you chain IncludeReference.ExampleBasic usage: fetch an entry and read its titleusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Map the entry onto your own model classusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Product product = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Product>();
    Console.WriteLine($"{product.Title}: {product.Url}");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}

public class Product
{
    public string Uid { get; set; }
    public string Title { get; set; }
    public string Url { get; set; }
}Edge case: read the result, not the request objectusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

Entry request = client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").SetLocale("<LOCALE>").IncludeFallback();

try
{
    Entry entry = await request.Fetch<Entry>();

    // Fetch returns a new object. The request object still holds no title.
    Console.WriteLine(request.GetTitle() == null);
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## Get

Get returns the value of one top-level field of a fetched entry.

```
Returns: object. The value of the requested field.
ValidationThere is no client-side validation.Get returns null for a field the entry does not hold, and for a null key. It does not throw.BehaviorClient-side only. Get reads the response that Fetch stored and makes no request.Call it on the Entry that Fetch<Entry>() returns. On the request object from ContentType.Entry, it returns null for every field.The return type depends on the JSON value:text: stringnumber: int, long, or doubletrue or false: boolobject, such as a Group field or publish_details: Dictionary<string, object>array, such as a multiple field or a reference field: List<object>null: nullGet reads top-level keys only. Read a nested value from the dictionary or list it returns.For a typed result, map the entry onto your own class with Fetch<T> instead.ExampleBasic usage: read a text fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    string url = entry.Get("url") as string;
    Console.WriteLine(url ?? "The entry has no url field");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Read a nested value from a Group fieldusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();

    if (entry.Get("seo") is Dictionary<string, object> seo && seo.TryGetValue("title", out object seoTitle))
        Console.WriteLine(seoTitle);
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID of the field to read.

## GetContentType

GetContentType returns the UID of the content type that the entry belongs to.

```
Returns: string. The UID of the entry's content type.
ValidationThere is no client-side validation.Throws NullReferenceException on an Entry that the SDK built while mapping your own model class, such as an Entry-typed property. That object holds no content type.BehaviorClient-side only. GetContentType makes no request.It works on both kinds of Entry object: the request object from ContentType.Entry, and the result of Fetch or of Find on a Query.The value is the content type UID you passed to client.ContentType, not a value read from the response.ExampleBasic usage: read the content type UIDusing System;
using Contentstack.Core;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

Entry entry = client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>");
Console.WriteLine(entry.GetContentType());
```

## GetCreateAt

GetCreateAt returns the creation time of the entry, from the created\_at field of a fetched entry.

```
Returns: DateTime. The entry's creation time.
ValidationThere is no client-side validation.GetCreateAt returns DateTime.MinValue when the entry has no created_at field or the value is not a date. It does not throw.BehaviorClient-side only. GetCreateAt reads the response that Fetch stored and makes no request.The SDK parses the value with DateTime.Parse. A timestamp with a time zone, such as a Z suffix, comes back converted to the local time zone of the machine, with DateTimeKind.Local. Call ToUniversalTime() for UTC.On the request object from ContentType.Entry, it returns DateTime.MinValue.Use the GetUpdateAt method for the time of the last update.ExampleBasic usage: read the creation time in UTCusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    DateTime createdAt = entry.GetCreateAt();

    if (createdAt == DateTime.MinValue)
        Console.WriteLine("No creation time in the response");
    else
        Console.WriteLine(createdAt.ToUniversalTime().ToString("o"));
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## GetCreatedBy

GetCreatedBy returns the UID of the user who created the entry, from the created\_by field of a fetched entry.

```
Returns: string. The UID of the user who created the entry.
ValidationThere is no client-side validation.GetCreatedBy returns null when the entry has no created_by field. It does not throw.BehaviorClient-side only. GetCreatedBy reads the response that Fetch stored and makes no request.On the request object from ContentType.Entry, it returns null.The GetUpdatedBy method returns an empty string, not null, for a missing field. Check both with string.IsNullOrEmpty.ExampleBasic usage: read the creator UIDusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    string createdBy = entry.GetCreatedBy();
    Console.WriteLine(string.IsNullOrEmpty(createdBy) ? "No creator in the response" : createdBy);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## GetDeletedAt

GetDeletedAt returns the value of the deleted\_at field of a fetched entry as a date.

```
Returns: DateTime. The entry's deletion time.
ValidationThere is no client-side validation.GetDeletedAt returns DateTime.MinValue when the entry has no deleted_at field or the value is not a date. It does not throw.BehaviorClient-side only. GetDeletedAt reads the response that Fetch stored and makes no request.The SDK parses the value with DateTime.Parse. A timestamp with a time zone, such as a Z suffix, comes back converted to the local time zone of the machine.Compare the result with DateTime.MinValue before you use it.Use the GetDeletedBy method for the UID of the user who deleted the entry.ExampleBasic usage: check for a deletion timeusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    DateTime deletedAt = entry.GetDeletedAt();
    Console.WriteLine(deletedAt == DateTime.MinValue ? "No deletion time in the response" : deletedAt.ToString("o"));
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## GetDeletedBy

GetDeletedBy returns the value of the deleted\_by field of a fetched entry.

```
Returns: string. The UID of the user who deleted the entry.
ValidationThrows KeyNotFoundException when the entry has no deleted_by field, unlike the other getters on Entry, which return an empty value.On the request object from ContentType.Entry, it also throws KeyNotFoundException.BehaviorClient-side only. GetDeletedBy reads the response that Fetch stored and makes no request.To read the field without the exception, use the Get method, which returns null for a missing field.ExampleBasic usage: read the field safelyusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();

    // Get returns null for a missing field. GetDeletedBy would throw.
    Console.WriteLine(entry.Get("deleted_by") == null ? "No deleted_by field" : entry.GetDeletedBy());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## GetHTMLText

GetHTMLText converts the Markdown in one field of a fetched entry to HTML.

```
Returns: string. The field's Markdown rendered as HTML.
ValidationThrows ArgumentNullException if markdownKey is null.GetHTMLText returns an empty string when the entry has no such field or the field value is null. It does not throw in either case.BehaviorClient-side only. GetHTMLText reads the response that Fetch stored and makes no request.The SDK converts the text with the Markdig library, with its advanced extensions turned on, such as tables and task lists.On a Markdown field that holds multiple values, GetHTMLText does not convert the values. It converts the name of the list type instead. See the GetMultipleHTMLText method for multiple-value fields.GetHTMLText handles Markdown fields only. To render a Rich Text Editor field with its embedded items, see the includeEmbeddedItems method.ExampleBasic usage: convert a Markdown field to HTMLusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    string html = entry.GetHTMLText("description");
    Console.WriteLine(html.Length == 0 ? "No Markdown in the description field" : html);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

UID of the Markdown field to convert.

## GetMetadata

GetMetadata returns the metadata of a fetched entry.

```
Returns: Dictionary<string, object>. The entry's metadata.
ValidationThere is no client-side validation.GetMetadata returns null when the response has no _metadata key. It does not throw.BehaviorClient-side only. GetMetadata returns the Metadata property, which the SDK fills from the _metadata key of the response. It makes no request.The API returns _metadata only when the request asks for it. Chain the IncludeMetadata method before Fetch. See Get a single entry in the Content Delivery API reference.Nested objects come back as Dictionary<string, object> and arrays as List<object>.ExampleBasic usage: list the metadata keysusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .IncludeMetadata()
        .Fetch<Entry>();

    Dictionary<string, object> metadata = entry.GetMetadata();
    Console.WriteLine(metadata == null ? "No metadata" : string.Join(", ", metadata.Keys));
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## GetMultipleHTMLText

GetMultipleHTMLText converts each value of a multiple-value Markdown field to HTML.

```
Returns: List<string>. The field's Markdown values rendered as HTML.
ValidationThrows ArgumentNullException if markdownKey is null.GetMultipleHTMLText returns an empty list when the entry has no such field or the value is not a list of values. It does not throw.BehaviorClient-side only. GetMultipleHTMLText reads the response that Fetch stored and makes no request.The SDK converts each value with the Markdig library, with its advanced extensions turned on, and keeps the order of the values.Use the GetHTMLText method for a single-value Markdown field.ExampleBasic usage: convert a multiple-value Markdown fieldusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    List<string> sections = entry.GetMultipleHTMLText("sections");
    Console.WriteLine($"{sections.Count} sections converted");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Workaround: convert the values with Markdigusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;
using Markdig;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();

    // The same pipeline the SDK uses. Markdig installs with the SDK.
    MarkdownPipeline pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
    List<string> sections = new List<string>();

    if (entry.Get("sections") is List<object> values)
    {
        foreach (object value in values)
            sections.Add(Markdown.ToHtml(value?.ToString() ?? string.Empty, pipeline));
    }
    Console.WriteLine($"{sections.Count} sections converted");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID of the multiple-value Markdown field.

## GetTags

GetTags returns the tags of a fetched entry.

```
Returns: object[]. The entry's tags.
ValidationThere is no client-side validation.GetTags returns null when the entry has no tags field. It does not throw.BehaviorClient-side only. GetTags reads the response that Fetch stored and makes no request.GetTags does not read the Tags property, so a value from the SetTags method does not change its result.ExampleBasic usage: read the tagsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    object[] tags = entry.GetTags();
    Console.WriteLine(tags == null ? "No tags returned" : string.Join(", ", tags));
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Workaround: read the tags with Getusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();

    if (entry.Get("tags") is List<object> tags)
        Console.WriteLine(string.Join(", ", tags));
    else
        Console.WriteLine("The entry has no tags");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## GetTitle

GetTitle returns the title of a fetched entry.

```
Returns: string. The entry's title.
ValidationThere is no client-side validation.GetTitle returns null when the entry has no title field. It does not throw.BehaviorClient-side only. GetTitle returns the Title property, which the SDK fills from the title field of the response. It makes no request.On the request object from ContentType.Entry, it returns null. Call it on the Entry that Fetch returns.ExampleBasic usage: print the titleusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Edge case: the request object holds no titleusing System;
using Contentstack.Core;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

Entry request = client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>");

// Prints True: no Fetch result has filled this object.
Console.WriteLine(request.GetTitle() == null);
```

## GetUid

GetUid returns the UID of the entry.

```
Returns: string. The entry's UID.
ValidationThere is no client-side validation.BehaviorClient-side only. GetUid returns the Uid property and makes no request.It works on both kinds of Entry object:On the request object, it returns the UID you passed to ContentType.Entry or SetUid.On the result of Fetch, it returns the uid field of the response.ExampleBasic usage: read the UID of a fetched entryusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    Console.WriteLine(entry.GetUid());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## GetUpdateAt

GetUpdateAt returns the last update time of the entry, from the updated\_at field of a fetched entry.

```
Returns: DateTime. The entry's last update time.
ValidationThere is no client-side validation.GetUpdateAt returns DateTime.MinValue when the entry has no updated_at field or the value is not a date. It does not throw.BehaviorClient-side only. GetUpdateAt reads the response that Fetch stored and makes no request.The SDK parses the value with DateTime.Parse. A timestamp with a time zone, such as a Z suffix, comes back converted to the local time zone of the machine, with DateTimeKind.Local. Call ToUniversalTime() for UTC.On the request object from ContentType.Entry, it returns DateTime.MinValue.Use the GetCreateAt method for the creation time.ExampleBasic usage: read the last update time in UTCusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    DateTime updatedAt = entry.GetUpdateAt();

    if (updatedAt == DateTime.MinValue)
        Console.WriteLine("No update time in the response");
    else
        Console.WriteLine(updatedAt.ToUniversalTime().ToString("o"));
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## GetUpdatedBy

GetUpdatedBy returns the UID of the user who last updated the entry, from the updated\_by field of a fetched entry.

```
Returns: string. The UID of the user who last updated the entry.
ValidationThere is no client-side validation.GetUpdatedBy returns an empty string when the entry has no updated_by field. It does not throw.BehaviorClient-side only. GetUpdatedBy reads the response that Fetch stored and makes no request.On the request object from ContentType.Entry, it returns an empty string.The GetCreatedBy method returns null, not an empty string, for a missing field. Check both with string.IsNullOrEmpty.ExampleBasic usage: read the UID of the last editorusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    string updatedBy = entry.GetUpdatedBy();
    Console.WriteLine(string.IsNullOrEmpty(updatedBy) ? "No editor in the response" : updatedBy);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeBranch

IncludeBranch adds the \_branch key, which names the branch the entry belongs to, to the response.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation.Throws EntryException at once on a second call on the same entry, because the entry already holds the parameter.The API rejects an invalid request, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeBranch adds include_branch=true to the next Fetch call and makes no request.The API returns the unique ID of the branch under the top-level _branch key. See Get a single entry in the Content Delivery API reference.IncludeBranch does not choose the branch. The Branch option of the client, or the branch argument of Variant, decides which branch the request reads.See the IncludeBranch method of Query for the same option on a list of entries.ExampleBasic usage: read the branch of an entryusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .IncludeBranch()
        .Fetch<Entry>();
    Console.WriteLine(entry.Get("_branch"));
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeExceptReference

IncludeExceptReference expands one reference field and leaves the named fields out of its referenced entries.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation of keys or referenceKey.A null or empty keys leaves the request unchanged.A second call for the same referenceKey has no effect and raises no error.The API rejects an invalid value, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeExceptReference stores each key as an except[<referenceKey>][] query parameter for the next Fetch call and makes no request.When the entry has no include[] parameter yet, IncludeExceptReference also adds referenceKey as include[], so the API expands that field.When the entry already has an include[] parameter, from IncludeReference or an earlier IncludeExceptReference call, IncludeExceptReference leaves it as it is. To trim two reference fields, call IncludeReference with both field UIDs first.A later IncludeReference call has no effect, because the include[] parameter already exists.See Exclude operator in the Content Delivery API reference for the rules of except[<reference_field_uid>][].To leave out top-level fields of the entry itself, use the Except method.See the IncludeExceptReference method of Query for the same option on a list of entries.ExampleBasic usage: drop the body of each referenced authorusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .IncludeExceptReference(new string[] { "body" }, "author")
        .Fetch<Entry>();
    Console.WriteLine(entry.Get("author"));
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Edge case: trim two reference fieldsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // Without the IncludeReference call, only author would be expanded.
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .IncludeReference(new string[] { "author", "category" })
        .IncludeExceptReference(new string[] { "body" }, "author")
        .IncludeExceptReference(new string[] { "description" }, "category")
        .Fetch<Entry>();
    Console.WriteLine(entry.Get("category"));
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Fields of the referenced entries to leave out.

UID of the reference field.

## IncludeFallback

IncludeFallback returns the entry from the fallback locale when the requested locale has no published version.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation.Throws EntryException at once on a second call on the same entry, because the entry already holds the parameter.The API rejects an invalid request, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeFallback adds include_fallback=true to the next Fetch call and makes no request.The API then returns the published content of the fallback locale when the locale you set has none. See Get a single entry in the Content Delivery API reference.Pair it with the SetLocale method, which names the locale to request.See the IncludeFallback method of Query for the same option on a list of entries.ExampleBasic usage: fall back when a locale has no published versionusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .SetLocale("<LOCALE>")
        .IncludeFallback()
        .Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeMetadata

IncludeMetadata adds the entry's metadata to the response.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation.Throws EntryException at once on a second call on the same entry, because the entry already holds the parameter.The API rejects an invalid request, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeMetadata adds include_metadata=true to the next Fetch call and makes no request.The API returns the metadata under the _metadata key of the entry and groups it by extension UID. See Get a single entry in the Content Delivery API reference.On a fetched Entry, read it with the GetMetadata method or the Metadata property.See the IncludeMetadata method of Query for the same option on a list of entries.ExampleBasic usage: fetch an entry with its metadatausing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .IncludeMetadata()
        .Fetch<Entry>();

    Dictionary<string, object> metadata = entry.GetMetadata();
    Console.WriteLine(metadata == null ? "No metadata" : string.Join(", ", metadata.Keys));
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeOnlyReference

IncludeOnlyReference limits the referenced entries in one reference field to the fields you name.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation of keys or referenceKey.A null or empty keys leaves the request unchanged.A second call for the same referenceKey has no effect and raises no error.Without an earlier IncludeReference call, a second IncludeOnlyReference call for a different reference field throws ArgumentException at once. Calling IncludeReference first avoids it.The API rejects an invalid value, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeOnlyReference stores each key as an only[<referenceKey>][] query parameter for the next Fetch call and makes no request.The API applies the field list only to a reference field that the request also expands. See Only operator in the Content Delivery API reference.To limit the top-level fields of the entry itself, use the Only method.See the IncludeOnlyReference method of Query for the same option on a list of entries.ExampleBasic usage: keep only the title of each authorusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // IncludeReference expands the field. IncludeOnlyReference trims it.
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .IncludeReference("author")
        .IncludeOnlyReference(new string[] { "title" }, "author")
        .Fetch<Entry>();
    Console.WriteLine(entry.Get("author"));
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Edge case: trim two reference fieldsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // Name both fields in one IncludeReference call, then trim each one.
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .IncludeReference(new string[] { "author", "category" })
        .IncludeOnlyReference(new string[] { "title" }, "author")
        .IncludeOnlyReference(new string[] { "title", "url" }, "category")
        .Fetch<Entry>();
    Console.WriteLine(entry.Get("category"));
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Fields of the referenced entries to keep.

UID of the reference field.

## IncludeOwner

IncludeOwner requests the owner information of the entry in the response.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation.Throws EntryException at once on a second call on the same entry, because the entry already holds the parameter.The API rejects an invalid request, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeOwner adds the include_owner query parameter to the next Fetch call and makes no request.The SDK sends the parameter value as True.On a fetched Entry, the ToJson method returns the full response for the entry, including any owner details.See the IncludeOwner method of Query for the same option on a list of entries.ExampleBasic usage: request the owner detailsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .IncludeOwner()
        .Fetch<Entry>();
    Console.WriteLine(entry.ToJson());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeReference

IncludeReference returns the content of referenced entries in place of their UIDs, for the reference fields you name.

```
Returns: Entry. The same entry, for chaining.
OverloadsIncludeReference(string referenceField)IncludeReference(string[] referenceFields)ValidationThere is no client-side validation of the field UIDs.A null or empty value leaves the request unchanged.Only the first IncludeReference call on an entry takes effect. A second call, with either overload, has no effect and raises no error. Pass every reference field in one array.The API rejects an invalid value, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeReference stores each UID as an include[] query parameter for the next Fetch call and makes no request.Without this option, a reference field holds only the UIDs of the referenced entries. See Include Reference in the Content Delivery API reference.Name a reference field inside a Group or Modular Blocks field with dot notation, for example bank_offers.bank. See Include Reference Within Group.On a fetched Entry, Get returns an expanded reference field as a List<object>, with each referenced entry as a Dictionary<string, object>.The IncludeOnlyReference and IncludeExceptReference methods also write the include[] parameter. Call IncludeReference before either of them. If they run first, the IncludeReference call has no effect.To expand every reference field, use the AddParam method with include_all.See the IncludeReference method of Query for the same option on a list of entries.ExampleBasic usage: expand one reference fieldusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .IncludeReference("author")
        .Fetch<Entry>();

    if (entry.Get("author") is List<object> authors)
    {
        foreach (object item in authors)
        {
            if (item is Dictionary<string, object> author)
                Console.WriteLine(author["title"]);
        }
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}All parameters: expand several reference fields in one callusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // A second IncludeReference call would have no effect, so name every field here.
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .IncludeReference(new string[] { "author", "category" })
        .Fetch<Entry>();
    Console.WriteLine(entry.Get("category"));
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}Edge case: expand a reference field inside a Group fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .IncludeReference("bank_offers.bank")
        .Fetch<Entry>();
    Console.WriteLine(entry.Get("bank_offers"));
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID of the reference field to expand.

UIDs of the reference fields to expand.

## IncludeReferenceContentTypeUID

IncludeReferenceContentTypeUID requests the content type UID of each referenced entry in the response.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation.Throws EntryException at once on a second call on the same entry, because the entry already holds the parameter.The API rejects an invalid request, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeReferenceContentTypeUID adds the include_reference_content_type_uid query parameter to the next Fetch call and makes no request.The SDK sends the parameter value as True.Combine it with the IncludeReference method when you need both the content and the content type of each referenced entry.See the IncludeReferenceContentTypeUID method of Query for the same option on a list of entries.ExampleBasic usage: request the content type UIDs of referencesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .IncludeReference("author")
        .IncludeReferenceContentTypeUID()
        .Fetch<Entry>();
    Console.WriteLine(entry.Get("author"));
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## Only

Only limits the fetched entry to the named fields.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation of the field UIDs.A null or empty array leaves the request unchanged.A second Only call on the same entry has no effect and raises no error. Pass every field UID in one array.The API rejects an invalid value, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Only stores each UID as an only[BASE][] query parameter for the next Fetch call and makes no request.BASE refers to the top-level fields of the entry. Name a field inside a Group or Modular Blocks field with dot notation, for example seo.title. See Only operator in the Content Delivery API reference.To limit the fields of referenced entries, use the IncludeOnlyReference method instead.Use the Except method to name the fields to drop instead of the fields to keep.See the Only method of Query for the same option on a list of entries.ExampleBasic usage: keep the title and URL onlyusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .Only(new string[] { "title", "url" })
        .Fetch<Entry>();
    Console.WriteLine($"{entry.GetTitle()}: {entry.Get("url")}");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Edge case: keep one field inside a Group fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // Dot notation names the title field inside the seo group.
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .Only(new string[] { "title", "seo.title" })
        .Fetch<Entry>();
    Console.WriteLine(entry.Get("seo"));
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UIDs of the fields to keep.

## RemoveHeader

RemoveHeader deletes a header from the headers that SetHeader and Variant write on this entry.

```
Returns: void. This method returns nothing.
ValidationThrows ArgumentNullException if key is null.A name that the entry does not hold leaves the entry unchanged and raises no error.BehaviorClient-side only. RemoveHeader changes the headers the next Fetch call sends and makes no request.It removes only headers set on this entry by SetHeader or Variant. Headers from the content type or the client, such as api_key and access_token, stay in place.Removing x-cs-variant-uid makes Fetch return the base entry again.ExampleBasic usage: drop a variant before the next fetchusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

Entry request = client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Variant("<VARIANT_UID>");

try
{
    Entry variantEntry = await request.Fetch<Entry>();
    Console.WriteLine(variantEntry.GetTitle());

    request.RemoveHeader("x-cs-variant-uid");
    Entry baseEntry = await request.Fetch<Entry>();
    Console.WriteLine(baseEntry.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the header to remove.

## SetCachePolicy

SetCachePolicy records a cache policy on the entry.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation.C# typing accepts only a CachePolicy value, and the enum has one member, CachePolicy.NetworkOnly.BehaviorClient-side only. SetCachePolicy stores the value and makes no request.The SDK has no response cache. Fetch sends a network request every time, with or without this call, so SetCachePolicy does not change what Fetch does.CachePolicy lives in the Contentstack.Core.Internals namespace.See the SetCachePolicy method of Query for the same setting on a query.ExampleBasic usage: set the only available policyusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .SetCachePolicy(CachePolicy.NetworkOnly)
        .Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Cache policy for the entry's requests.

## SetHeader

SetHeader adds a request header that this entry sends with Fetch.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation of the header name or value.SetHeader ignores the call when key or value is null, and raises no error.Fetch skips, without an error, a header that .NET does not let a request set directly, such as Content-Type or User-Agent.BehaviorClient-side only. SetHeader stores the header on this entry and makes no request.A second call with the same key replaces the value.A header set on the entry replaces a header of the same name from the content type or the client, for this entry's requests only.SetHeader returns nothing, so it does not chain. Call it as a separate statement before Fetch.Use the RemoveHeader method to remove a header that this method added.ExampleBasic usage: send a custom header with one entry requestusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

Entry request = client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>");
request.SetHeader("branch", "<BRANCH>");

try
{
    Entry entry = await request.Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the header.

Value of the header.

## SetLocale

SetLocale sets the locale of the entry that Fetch retrieves.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation of the locale code.The API rejects an invalid or unknown locale, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. SetLocale stores the locale query parameter for the next Fetch call and makes no request.A second SetLocale call replaces the locale. This differs from the other option methods on Entry.The API returns the entry only when it has a published version in that locale. See Get a single entry in the Content Delivery API reference. Chain the IncludeFallback method to get the fallback locale's content instead.The parameter name starts with an uppercase L. Write Locale: if you pass it as a named argument.See the SetLocale method of Query for the same option on a list of entries.ExampleBasic usage: fetch the entry in one localeusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .SetLocale("<LOCALE>")
        .Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Edge case: the second locale winsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // The request asks for <LOCALE> only. The earlier en-us value is gone.
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .SetLocale("en-us")
        .SetLocale(Locale: "<LOCALE>")
        .Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Locale code to fetch, such as en-us.

## SetTags

SetTags writes an array of tags to the Tags property of the entry object.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation. SetTags accepts null and stores it.BehaviorClient-side only. SetTags writes the Tags property and makes no request.The tags stay on the local object. Fetch does not send them, and the Content Delivery API cannot write content, so SetTags cannot change the tags of the stored entry.The GetTags method does not read the Tags property. Read Tags directly to get the value back.ExampleBasic usage: store tags on a local entry objectusing System;
using Contentstack.Core;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

Entry entry = client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>");
entry.SetTags(new string[] { "featured", "homepage" });

// Read the property, not GetTags.
Console.WriteLine(string.Join(", ", entry.Tags));
```

Tags to store on the object.

## SetUid

SetUid sets the UID of the entry that Fetch retrieves.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation.An empty or null UID makes the next Fetch call throw EntryException, because the SDK then requests the entry list path instead of one entry.BehaviorClient-side only. SetUid writes the Uid property and makes no request.The next Fetch call reads the entry with the new UID and keeps every option you chained before.SetUid returns nothing, so it does not chain.ExampleBasic usage: reuse one request for two entriesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

Entry request = client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").SetLocale("<LOCALE>");

try
{
    Entry first = await request.Fetch<Entry>();
    Console.WriteLine(first.GetTitle());

    request.SetUid("<ENTRY_UID>");
    Entry second = await request.Fetch<Entry>();
    Console.WriteLine(second.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

UID of the entry.

## ToJson

ToJson returns the raw JSON of a fetched entry.

```
Returns: JsonObject. The entry's raw JSON.
ValidationThere is no client-side validation.ToJson returns null on the request object from ContentType.Entry. It does not throw.BehaviorClient-side only. ToJson returns the entry object of the response that Fetch stored, as a System.Text.Json.Nodes.JsonObject. It makes no request.The object holds every field the API returned, including keys that no getter reads, such as _embedded_items and _branch.The SDK returns its own stored object, not a copy.ExampleBasic usage: print the entry as JSONusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").Fetch<Entry>();
    JsonObject json = entry.ToJson();
    Console.WriteLine(json?.ToJsonString());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## Variant

Variant fetches the entry with the content of one or more entry variants applied.

```
Returns: Entry. The same entry, for chaining.
OverloadsVariant(string variant_header, string branch = null)Variant(List<string> variant_headers, string branch = null)ValidationThere is no client-side validation of the variant UIDs or the branch.A null variant_header sends no variant header, so Fetch returns the base entry.A null variant_headers list throws ArgumentNullException at once.The API rejects an unknown variant or branch, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Variant sets two request headers for the next Fetch call and makes no request:x-cs-variant-uid, with the UIDs of a list joined by commas.branch, with the branch the SDK resolves from the branch argument.The SDK resolves the branch in this order:the branch argument, when it is not null, empty, or white spacethe Branch option of the clientmainThe branch header from Variant replaces the client's Branch option for this entry's requests.The API accepts variant aliases in place of variant UIDs. By default it accepts up to five values, and the first one takes priority over the rest. See Get single entry variant in the Content Delivery API reference.A second Variant call replaces both headers.To go back to the base entry, remove the variant header with the RemoveHeader method.See the Variant method of Query for the same option on a list of entries.ExampleBasic usage: fetch one variant of an entryusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .Variant("<VARIANT_UID>")
        .Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}All parameters: apply a list of variants from a specific branchusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

// List the variant UIDs or aliases in priority order.
List<string> variants = new List<string> { "<VARIANT_UID>" };

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .Variant(variants, "<BRANCH>")
        .Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}Edge case: one variant from a named branchusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // Without the branch argument, the SDK sends the client's Branch option, or main.
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .Variant("<VARIANT_UID>", branch: "<BRANCH>")
        .Fetch<Entry>();
    Console.WriteLine(entry.GetTitle());
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Variant UID or variant alias to apply.

Branch to read the variant from.

Variant UIDs or aliases, highest priority first.

## includeEmbeddedItems

includeEmbeddedItems adds the entries and assets embedded in the entry's Rich Text Editor (RTE) fields to the response.

```
Returns: Entry. The same entry, for chaining.
ValidationThere is no client-side validation.Throws EntryException at once on a second call on the same entry, because the entry already holds the parameter.The API rejects an invalid request, and Fetch throws EntryException when it sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. includeEmbeddedItems adds include_embedded_items[]=BASE to the next Fetch call and makes no request. The method name starts with a lowercase i.With BASE, the API returns the first level of embedded entries and assets under the _embedded_items key, with one list per RTE field UID. See Get information on embedded RTE objects in the Content Delivery API reference.includeEmbeddedItems always sends BASE. For nested embedded items, call the AddParam method instead, as AddParam("include_embedded_items[]", "RECURSIVE"), and add embedded_items_depth the same way if you need a depth limit. Calling both on one entry throws EntryException, because they write the same parameter.To render an RTE field as HTML with its embedded items, use the contentstack.utils package, which the SDK installs as a dependency. Map the entry onto a model class that implements its IEntryEmbedable interface. The client registers the converter for embedded objects, so Fetch<T> fills the embeddedItems property. Then pass the field and the model to Utils.RenderContent.See the includeEmbeddedItems method of Query for the same option on a list of entries.ExampleBasic usage: fetch an entry with its embedded itemsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Entry entry = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .includeEmbeddedItems()
        .Fetch<Entry>();
    Console.WriteLine(entry.Get("_embedded_items"));
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Render an RTE field as HTML with its embedded itemsusing System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Utils;
using Contentstack.Utils.Interfaces;
using Contentstack.Utils.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Article article = await client.ContentType("<CONTENT_TYPE_UID>")
        .Entry("<ENTRY_UID>")
        .includeEmbeddedItems()
        .Fetch<Article>();

    // RenderContent replaces each embedded item tag in the field with HTML.
    string html = Utils.RenderContent(article.Body, new Options(article));
    Console.WriteLine(html);
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}

public class Article : IEntryEmbedable
{
    public string Uid { get; set; }
    public string Title { get; set; }
    public string Body { get; set; }

    [JsonPropertyName("_embedded_items")]
    public Dictionary<string, List<IEmbeddedObject>> embeddedItems { get; set; }
}
```

## Entry

Set key/value attributes of Metadata.

Set key/value attributes of an current entry instance.

Set array of Tags

Title of an entry

This is Entry Uid of an entry.

## Entry | .NET Delivery SDK | Contentstack

The Entry class in the .NET Delivery SDK fetches one published entry of a content type and reads its fields, metadata, and system values.

## Global Fields

A global field is a reusable field, or group of fields, that you define once and reuse across content types in a stack. Use the GlobalField class to read one global field by its UID, for example to inspect its schema at runtime.

client.GlobalField(uid) on [ContentstackClient](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient) returns a GlobalField:

Name

Type

Description

globalFieldName

string

UID of the global field to read.

To list every global field in the stack, use [GlobalFieldQuery](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/global-field-query) instead.

## Fetch

Fetch reads one global field by its UID.

```
Returns: Task<JsonObject>. The requested global field as a JSON object.
ValidationThrows ArgumentException before the request if param holds a key that the instance already sends, because the SDK adds each query parameter once. The instance always sends environment, and sends include_branch or include_global_field_schema after the matching modifier.Throws GlobalFieldException if the request fails, for example for an unknown global field UID.Throws GlobalFieldException if the response has no global_field object, for example when the instance holds no UID.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorCalls GET /global_fields/{global_field_uid} (Get a single global field) and makes one HTTP request per call.Returns the global_field object of the response as a JsonObject. There is no generic overload, so read the fields from the object or deserialize it yourself.Sends the environment, the values from IncludeBranch and IncludeGlobalFieldSchema, and every entry of param.param applies to this call only. The SDK does not store it on the instance.Sends the client headers and the headers from SetHeader. A header set on the instance replaces a client header of the same name.ExampleBasic usage: read a global fieldusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject globalField = await client.GlobalField("<GLOBAL_FIELD_UID>").Fetch();
    Console.WriteLine($"{globalField["uid"]}: {globalField["title"]}");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}All parameters: send extra query parametersusing System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Dictionary<string, object> param = new Dictionary<string, object>
    {
        { "include_global_field_schema", "true" },
        { "include_branch", "true" }
    };

    JsonObject globalField = await client.GlobalField("<GLOBAL_FIELD_UID>").Fetch(param);
    Console.WriteLine($"{globalField["title"]} on branch {globalField["_branch"]}");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Extra query parameters to send with the request.

## IncludeBranch

IncludeBranch adds the \_branch key, the UID of the branch that holds the global field, to the response.

```
Returns: GlobalField. The same global field, for chaining.
ValidationThrows ArgumentException if the instance already holds include_branch, because the SDK adds each query parameter once. This happens when you call IncludeBranch twice on one instance.Fetch also throws ArgumentException if its param dictionary repeats include_branch.An invalid value surfaces as a ContentstackException (or a subclass) when Fetch sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeBranch stores include_branch and makes no request.Fetch sends the value, and the API adds the _branch top-level key to the response (Get a single global field).Does not choose the branch. The Branch option on ContentstackOptions sets the branch the SDK reads from.ExampleBasic usage: read a global field with its branchusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject globalField = await client.GlobalField("<GLOBAL_FIELD_UID>")
        .IncludeBranch()
        .Fetch();
    Console.WriteLine($"{globalField["uid"]} is on branch {globalField["_branch"]}");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeGlobalFieldSchema

IncludeGlobalFieldSchema adds the schema of the global field to the response.

```
Returns: GlobalField. The same global field, for chaining.
ValidationThrows ArgumentException if the instance already holds include_global_field_schema, because the SDK adds each query parameter once. This happens when you call IncludeGlobalFieldSchema twice on one instance.Fetch also throws ArgumentException if its param dictionary repeats include_global_field_schema.An invalid value surfaces as a ContentstackException (or a subclass) when Fetch sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeGlobalFieldSchema stores include_global_field_schema and makes no request.Fetch sends the value, and the API adds the schema of the global field to the response (Get a single global field).ExampleBasic usage: read a global field with its schemausing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject globalField = await client.GlobalField("<GLOBAL_FIELD_UID>")
        .IncludeGlobalFieldSchema()
        .Fetch();
    JsonArray schema = globalField["schema"]?.AsArray() ?? new JsonArray();
    Console.WriteLine($"{globalField["title"]} has {schema.Count} fields");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## RemoveHeader

RemoveHeader removes a header that SetHeader set on this global field instance.

```
Returns: void. This method returns nothing.
ValidationThrows ArgumentNullException if key is null, because the SDK looks the header up by name.A key that the instance does not hold changes nothing and does not throw.BehaviorClient-side only. RemoveHeader makes no request.Removes only the headers set with SetHeader on this instance. The client headers, for example api_key and access_token, stay on every request.After the removal, a client header of the same name applies again to this instance.ExampleBasic usage: remove a header before the next requestusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

GlobalField globalField = client.GlobalField("<GLOBAL_FIELD_UID>");
globalField.SetHeader("branch", "<BRANCH>");

// Read from the branch set on the client again
globalField.RemoveHeader("branch");

try
{
    JsonObject result = await globalField.Fetch();
    Console.WriteLine(result["title"]);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the header to remove.

## SetHeader

SetHeader sets a request header on this global field instance.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation of the header name or value.A null key or value changes nothing. SetHeader ignores the call and does not throw.BehaviorClient-side only. SetHeader stores the header and makes no request. A second call with the same key replaces the first value.Fetch on this instance sends the header. Other instances and the client keep their own headers.A header set here replaces a client header of the same name for this instance, for example the branch header that the Branch option sets.Use the RemoveHeader method to remove the header again.ExampleBasic usage: read a global field from another branchusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

GlobalField globalField = client.GlobalField("<GLOBAL_FIELD_UID>");

// The branch header on this instance replaces the branch set on the client
globalField.SetHeader("branch", "<BRANCH>");

try
{
    JsonObject result = await globalField.Fetch();
    Console.WriteLine(result["title"]);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the header, for example branch.

Value of the header.

## GlobalField | .NET Delivery SDK | Contentstack

The GlobalField class in the .NET Delivery SDK reads one global field by its UID, with optional schema and branch details.

## Global Field Query

A global field is a reusable field, or group of fields, that you define once and reuse across content types in a stack. Use the GlobalFieldQuery class to list every global field in the stack in one request.

client.GlobalFieldQuery() on [ContentstackClient](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient) returns a GlobalFieldQuery. It takes no arguments. To read one global field by its UID, use [GlobalField](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/global-fields) instead.

## Find

Find lists every global field in the stack.

```
Returns: Task<JsonObject>. The response body as a JSON object.
ValidationThrows ArgumentException before the request if param holds a key that the instance already sends, because the SDK adds each query parameter once. The instance always sends environment, and sends include_branch or include_global_field_schema after the matching modifier.Throws ContentstackException if the request fails. Unlike GlobalField, this class throws the base type, not GlobalFieldException.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorCalls GET /global_fields (Get all global fields) and makes one HTTP request per call.Returns the whole response body as a JsonObject. Read the global fields from its global_fields array.Sends the environment, the values from IncludeBranch and IncludeGlobalFieldSchema, and every entry of param.param applies to this call only. The SDK does not store it on the instance.ExampleBasic usage: list the global fieldsusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject body = await client.GlobalFieldQuery().Find();
    JsonArray globalFields = body["global_fields"]?.AsArray() ?? new JsonArray();
    foreach (JsonNode globalField in globalFields)
    {
        Console.WriteLine($"{globalField?["uid"]}: {globalField?["title"]}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}All parameters: send extra query parametersusing System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Dictionary<string, object> param = new Dictionary<string, object>
    {
        { "include_global_field_schema", "true" },
        { "include_branch", "true" }
    };

    JsonObject body = await client.GlobalFieldQuery().Find(param);
    Console.WriteLine(body["global_fields"]?.AsArray().Count);
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Extra query parameters to send with the request.

## IncludeBranch

IncludeBranch adds the \_branch key, which names the branch that holds the global fields, to the response.

```
Returns: GlobalFieldQuery. The same global field query, for chaining.
ValidationThrows ArgumentException if the instance already holds include_branch, because the SDK adds each query parameter once. This happens when you call IncludeBranch twice on one instance.Find also throws ArgumentException if its param dictionary repeats include_branch.An invalid value surfaces as a ContentstackException when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeBranch stores include_branch and makes no request.Find sends the value, and the API adds the _branch top-level key to the response (Get all global fields).Does not choose the branch. The Branch option on ContentstackOptions sets the branch the SDK reads from.ExampleBasic usage: list the global fields with branch detailsusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject body = await client.GlobalFieldQuery()
        .IncludeBranch()
        .Find();
    Console.WriteLine(body.ToJsonString());
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeGlobalFieldSchema

IncludeGlobalFieldSchema adds the schema of each global field to the response.

```
Returns: GlobalFieldQuery. The same global field query, for chaining.
ValidationThrows ArgumentException if the instance already holds include_global_field_schema, because the SDK adds each query parameter once. This happens when you call IncludeGlobalFieldSchema twice on one instance.Find also throws ArgumentException if its param dictionary repeats include_global_field_schema.An invalid value surfaces as a ContentstackException when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeGlobalFieldSchema stores include_global_field_schema and makes no request.Find sends the value, and the API adds the schema of each global field to the response (Get all global fields).ExampleBasic usage: list the global fields with their schemasusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject body = await client.GlobalFieldQuery()
        .IncludeGlobalFieldSchema()
        .Find();
    foreach (JsonNode globalField in body["global_fields"]?.AsArray() ?? new JsonArray())
    {
        JsonArray schema = globalField?["schema"]?.AsArray() ?? new JsonArray();
        Console.WriteLine($"{globalField?["uid"]} has {schema.Count} fields");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## GlobalFieldQuery | .NET Delivery SDK | Contentstack

The GlobalFieldQuery class in the .NET Delivery SDK lists every global field in a stack, with optional schema and branch details.

## Query

A query narrows the entries of one content type to those that match the conditions you set. Use this class to do the following:

*   match field values with comparisons, value lists, patterns, and existence checks
*   filter entries by the entries their reference fields point to
*   combine conditions with $and and $or
*   choose the locale, variants, referenced content, and fields the response contains
*   sort, page, and send the request

Get a Query from client.ContentType("<CONTENT\_TYPE\_UID>").Query(). Every method below works on that query. The Taxonomy class inherits these methods to filter entries across content types. See the [Taxonomy](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/taxonomy) class page.

## AddParam

AddParam adds a URL query parameter that has no dedicated method.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key is null, because the SDK stores each parameter under its name.Throws QueryFilterException if the query already holds a parameter named key, for example from an earlier AddParam or Limit call, because the SDK stores each parameter once. See Options set once per query on the Query class page.A null value is not an error. The SDK sends the parameter with an empty value.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. AddParam stores key and value as a URL query parameter and makes no request. Find, FindOne and Count send <key>=<value>.AddParam writes a URL query parameter, not a condition in the query parameter. To add a condition, use the Where method.The SDK does not URL-encode value, so a value that holds & or # changes the request URL. See Request URL encoding in the SDK-Wide Notes of the usage guide.For example, include_taxonomy_terms=true resolves the taxonomy term names in each entry. See Get all entries in the Content Delivery API reference.ExampleBasic usage: resolve taxonomy termsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .AddParam("include_taxonomy_terms", "true")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Get("taxonomies"));
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Several parameters: expand all references two levels deepusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .AddParam("include_all", "true")
        .AddParam("include_all_depth", "2")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Name of the query parameter.

Value of the query parameter.

## AddQuery

AddQuery adds an equality condition with a string value to the query conditions.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key or value is null, because the condition needs a field and a value to compare.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. AddQuery stores { "<key>": "<value>" } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.AddQuery stores the same condition as the Where method with a string value. Use Where for numbers, booleans and operator objects.AddQuery writes to the query parameter only. To add a separate URL query parameter, use the AddParam method.The API returns the entries whose field value matches value. See Equals Operator in the Content Delivery API reference.ExampleBasic usage: match an exact titleusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .AddQuery("title", "Home")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

UID or dotted path of the field to filter.

String value the field must equal.

## And

And matches entries that satisfy every condition in a list of sub-queries.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if queryObjects is null or empty, because there is nothing to combine.Throws QueryFilterException if the list holds a null item, because the SDK reads the conditions of each item.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. And stores { "$and": [ <conditions of each sub-query> ] } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.A second And call replaces the first list. It does not throw.The SDK reads only the conditions of each sub-query. Their content type, locale, limit and other parameters have no effect.The SDK keeps a reference to each sub-query's conditions, not a copy. A condition you add to a sub-query before Find also reaches the request.Conditions on the main query outside the list still apply, so an entry must also satisfy them.The API returns the entries that satisfy all the sub-query conditions. See AND Operator in the Content Delivery API reference.To match entries that satisfy any one sub-query, use the Or method.ExampleRange: bound one field on both sidesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;
using System.Collections.Generic;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // Each sub-query holds one condition on the same field
    Query fromQuery = client.ContentType("<CONTENT_TYPE_UID>").Query().GreaterThanOrEqualTo("price", 100);
    Query toQuery = client.ContentType("<CONTENT_TYPE_UID>").Query().LessThan("price", 500);

    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .And(new List<Query> { fromQuery, toQuery })
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Sub-queries whose conditions the API combines.

## Ascending

Ascending sorts the entries by a field in ascending order.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key is null, because the sort needs a field.Throws QueryFilterException on a second call on the same query, because the SDK stores the asc parameter once. See Options set once per query on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Ascending sets the asc URL query parameter and makes no request. Find, FindOne and Count send asc=<key>.The API sorts the entries in ascending order of the field value. See Order by asc in the Content Delivery API reference.Ascending and the Descending method write different parameters, so a query can hold both.ExampleBasic usage: sort by a fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Ascending("updated_at")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

UID of the field to sort by.

## AssetFields

AssetFields requests extra field groups for the assets in each entry.

```
Returns: Query. The same query, for chaining.
ValidationCalling it with no arguments, null, or an empty array is not an error. AssetFields adds nothing.Throws ArgumentException on a second call with arguments, because the SDK stores the asset_fields[] parameter once. Pass every group in one call.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. AssetFields sets the asset_fields[] URL query parameter and makes no request. Find, FindOne and Count send one asset_fields[]=<group> pair per argument.fields is a params array, so you can pass the groups as separate arguments or as one array.With visual_markups, the API returns the hotspot and bounding-box annotations of each embedded asset under the visual_markups key. See Get all entries in the Content Delivery API reference.ExampleBasic usage: request visual markups for assetsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .AssetFields("visual_markups")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Asset field groups to include.

## ContainedIn

ContainedIn matches entries whose field value equals one of the given values.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key or values is null, because the condition needs a field and a value to compare.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.ContainedIn does not check the array length. The SDK sends an empty array as given.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. ContainedIn copies values into a list, stores { "<key>": { "$in": [ <values> ] } } in the query conditions, and makes no request. Find, FindOne and Count send the conditions as the query parameter.The SDK serializes each value with System.Text.Json, so numbers and strings keep their JSON types.The API returns the entries whose field value matches any of values. See Array Equals Operator in the Content Delivery API reference.To exclude a list of values, use the NotContainedIn method.ExampleBasic usage: match a list of stringsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .ContainedIn("color", new object[] { "Gold", "Black" })
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Number field: match a list of pricesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .ContainedIn("price", new object[] { 101, 749 })
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID or dotted path of the field to filter.

Values the field may equal.

## Count

Count sends the query and returns the number of matching entries, without the entries.

```
Returns: Task<JsonObject>. The response body as a JSON object.
ValidationThrows QueryFilterException on a second Count call on the same query, because the SDK stores the count parameter once. Build a new query for each count.Count throws QueryFilterException, a subclass of ContentstackException, when the API rejects the request. StatusCode, ErrorCode, Message and Errors carry the API's error details.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorCount sets the count=true URL query parameter, then sends the same request as the Find method with every condition the query holds.With count=true, the API returns only the number of matching entries. See Count in the Content Delivery API reference.Count returns the raw response body as a JsonObject from System.Text.Json.Nodes, not a typed value.Known issue: count=true stays on the query, so a later Find on the same query does not return the entries. Build a separate query for Find.To get the entries and the total in one request, use the IncludeCount method with Find.ExampleBasic usage: count matching entriesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;
using System.Text.Json.Nodes;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Exists("url")
        .Count();
    Console.WriteLine(result.ToJsonString());
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## Descending

Descending sorts the entries by a field in descending order.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key is null, because the sort needs a field.Throws QueryFilterException on a second call on the same query, because the SDK stores the desc parameter once. See Options set once per query on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Descending sets the desc URL query parameter and makes no request. Find, FindOne and Count send desc=<key>.The API sorts the entries in descending order of the field value. See Order by desc in the Content Delivery API reference.Descending and the Ascending method write different parameters, so a query can hold both.ExampleBasic usage: sort by a fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Descending("updated_at")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

UID of the field to sort by.

## Except

Except leaves the listed top-level fields out of each entry.

```
Returns: Query. The same query, for chaining.
ValidationA null or empty array is not an error. Except adds nothing.A second call on the same query is not an error. The SDK keeps the first list and ignores the second, without a warning. Pass every field in one call.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Except sets the except[BASE][] URL query parameter and makes no request. Find, FindOne and Count send one pair per field.BASE refers to the top-level fields of the entry. The API returns every field of each entry except the listed ones. See Exclude Operator in the Content Delivery API reference.To shape the fields of a referenced entry, use the IncludeExceptReference method.ExampleBasic usage: leave out two fieldsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Except(new string[] { "body", "seo" })
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Field UIDs to leave out.

## Exists

Exists matches entries that have a value for the given field.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key is null, because the condition needs a field.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Exists stores { "<key>": { "$exists": true } } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.The API returns the entries in which the field exists. See Exists in the Content Delivery API reference.To match entries that lack the field, use the NotExists method.ExampleBasic usage: check a fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Exists("url")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Field inside a group: check a subfieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Exists("seo.meta_title")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID or dotted path of the field to filter.

## Find

Find sends the query and returns the matching entries of the content type.

```
Returns: Task<ContentstackCollection<T>>. The matching entries.
ValidationFind throws QueryFilterException, a subclass of ContentstackException, when the API rejects the request. StatusCode, ErrorCode, Message and Errors carry the API's error details.For a network failure with no HTTP response, such as a timeout, the same exception carries StatusCode InternalServerError (500) and ErrorCode 0. Read Message and InnerException for the cause.Find throws ContentstackException if the entries in the response do not bind to T. The InnerException holds the JsonException.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorFind sends one GET /content_types/{content_type_uid}/entries request with the client's environment, the query conditions as the query parameter, and every URL query parameter and header that the query holds.Find returns one page. Without the Limit method, the API returns the first 100 entries. See Pagination in the Content Delivery API reference.The returned ContentstackCollection<T> holds the entries in Items and is enumerable. Count holds the total number of matches only after the IncludeCount method. Skip and Limit on the collection read 0. See the ContentstackCollection class page.With T set to your own class, the SDK binds JSON field names to properties without regard to case, so title fills Title.Find does not change the query, so you can call it again to send the same request.ExampleBasic usage: find entriesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Where("title", "Home")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine($"{entry.Uid} {entry.Title}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Model class: bind entries to your own typeusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Product> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Limit(10)
        .Find<Product>();
    foreach (Product product in result)
    {
        Console.WriteLine($"{product.Title} {product.Url}");
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}

public class Product
{
    public string Uid { get; set; }
    public string Title { get; set; }
    public string Url { get; set; }
}
```

## FindOne

FindOne sends the query with a limit of one and returns the first matching entry.

```
Returns: Task<ContentstackCollection<T>>. A collection holding at most one matching entry.
ValidationFindOne throws QueryFilterException, a subclass of ContentstackException, when the API rejects the request. StatusCode, ErrorCode, Message and Errors carry the API's error details.FindOne throws ContentstackException if the entry in the response does not bind to T.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorFindOne sets the limit URL query parameter to 1, replacing any value from the Limit method, then sends the same request as the Find method.The change to limit stays on the query. A later Find on the same query also returns at most one entry.FindOne returns a collection, not a single entry. Read the entry from Items. An empty collection means no entry matched.The Skip, Ascending and Descending methods decide which entry comes first.ExampleBasic usage: get the newest matching entryusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;
using System.Linq;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Descending("updated_at")
        .FindOne<Entry>();
    Entry entry = result.Items.FirstOrDefault();
    Console.WriteLine(entry == null ? "No match" : entry.Title);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## GreaterThan

GreaterThan matches entries whose field value is greater than the given value.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key or value is null, because the condition needs a field and a value to compare.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.GreaterThan does not check that value suits the field type.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. GreaterThan stores { "<key>": { "$gt": <value> } } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.The SDK serializes value with System.Text.Json, so a number goes as a JSON number and a string as a JSON string.The API returns the entries whose field value is greater than value, not equal to it. See Greater Than in the Content Delivery API reference.On a date field such as updated_at, pass the date as an ISO 8601 string, for example "2026-01-01".To bound one field on both sides, build each condition in its own query and combine them with the And method.ExampleBasic usage: compare a number fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .GreaterThan("price", 100)
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Date field: match entries updated after a dateusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .GreaterThan("updated_at", "2026-01-01")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID or dotted path of the field to filter.

Lower bound the field value must exceed.

## GreaterThanOrEqualTo

GreaterThanOrEqualTo matches entries whose field value is greater than or equal to the given value.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key or value is null, because the condition needs a field and a value to compare.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.GreaterThanOrEqualTo does not check that value suits the field type.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. GreaterThanOrEqualTo stores { "<key>": { "$gte": <value> } } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.The SDK serializes value with System.Text.Json, so a number goes as a JSON number and a string as a JSON string.The API returns the entries whose field value is greater than or equal to value. See Greater Than Or Equal To in the Content Delivery API reference.On a date field such as updated_at, pass the date as an ISO 8601 string, for example "2026-01-01".To bound one field on both sides, build each condition in its own query and combine them with the And method.ExampleBasic usage: compare a number fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .GreaterThanOrEqualTo("price", 100)
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Date field: match entries updated on or after a dateusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .GreaterThanOrEqualTo("updated_at", "2026-01-01")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID or dotted path of the field to filter.

Lower bound the field value must reach.

## IncludeBranch

IncludeBranch adds the branch of each entry to the response.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException on a second call on the same query, because the SDK stores the include_branch parameter once. See Options set once per query on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeBranch sets the include_branch URL query parameter and makes no request. Find, FindOne and Count send include_branch=true.The API adds the _branch top-level key, which states the unique ID of the branch the entry belongs to. See Get all entries in the Content Delivery API reference.IncludeBranch does not choose the branch. Set Branch on the client options, or pass branch to the Variant method.ExampleBasic usage: include the branch keyusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .IncludeBranch()
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Get("_branch"));
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeCount

IncludeCount adds the total number of matching entries to the response.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException on a second call on the same query, because the SDK stores the include_count parameter once. See Options set once per query on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeCount sets the include_count URL query parameter and makes no request. Find, FindOne and Count send include_count=true.The API adds the total number of matching entries, not only those on the current page, as count. See Count in the Content Delivery API reference.Find and FindOne read count into the Count property of the returned collection. Without IncludeCount, Count reads 0.To get only the number, without the entries, use the Count method.ExampleBasic usage: read the total number of matchesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Limit(10)
        .IncludeCount()
        .Find<Entry>();
    // Count holds the total number of matches, not the page size
    Console.WriteLine($"Total matches: {result.Count}");
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeExceptReference

IncludeExceptReference expands a reference field and leaves out the listed fields of each referenced entry.

```
Returns: Query. The same query, for chaining.
ValidationA null or empty keys array is not an error. IncludeExceptReference adds nothing.A second call with the same referenceKey is not an error. The SDK keeps the first list and ignores the second.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeExceptReference makes no request. It sets two URL query parameters:include[]=<referenceKey>, only when the query has no reference list yet.except[<referenceKey>][], one pair per item in keys.Known issue: When the query already has a reference list, IncludeExceptReference does not add referenceKey to it, so the API returns that reference field as UIDs. Pass every reference field to one IncludeReference call with an array before you call IncludeExceptReference.Call IncludeReference before IncludeExceptReference, not after. IncludeReference throws ArgumentException when a reference list exists.The API returns every field of each referenced entry except the listed ones. See Exclude Operator in the Content Delivery API reference.ExampleBasic usage: shape one reference fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .IncludeExceptReference(new string[] { "title", "email" }, "author")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Get("author"));
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Several reference fields: list them in IncludeReference firstusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .IncludeReference(new string[] { "author", "category" })
        .IncludeExceptReference(new string[] { "title", "email" }, "author")
        .IncludeExceptReference(new string[] { "title" }, "category")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Get("category"));
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Field UIDs of the referenced entry to leave out.

UID of the reference field to expand.

## IncludeFallback

IncludeFallback returns content from the fallback locale for entries not published in the requested locale.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException on a second call on the same query, because the SDK stores the include_fallback parameter once. See Options set once per query on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeFallback sets the include_fallback URL query parameter and makes no request. Find, FindOne and Count send include_fallback=true.The API includes the published content from the fallback locale when the requested locale has no published content. See Get all entries in the Content Delivery API reference.Pair it with the SetLocale method to name the requested locale.ExampleBasic usage: fall back for a localeusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .SetLocale("<LOCALE>")
        .IncludeFallback()
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeMetadata

IncludeMetadata adds the metadata of each entry to the response.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException on a second call on the same query, because the SDK stores the include_metadata parameter once. See Options set once per query on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeMetadata sets the include_metadata URL query parameter and makes no request. Find, FindOne and Count send include_metadata=true.The API adds each entry's extension metadata under the _metadata key. See Get all entries in the Content Delivery API reference.ExampleBasic usage: include entry metadatausing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .IncludeMetadata()
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Get("_metadata"));
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeOnlyReference

IncludeOnlyReference expands a reference field and returns only the listed fields of each referenced entry.

```
Returns: Query. The same query, for chaining.
ValidationA null or empty keys array is not an error. IncludeOnlyReference adds nothing.A second call with the same referenceKey is not an error. The SDK keeps the first list and ignores the second.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeOnlyReference makes no request. It sets two URL query parameters:include[]=<referenceKey>, only when the query has no reference list yet.only[<referenceKey>][], one pair per item in keys.Known issue: When the query already has a reference list, IncludeOnlyReference does not add referenceKey to it, so the API returns that reference field as UIDs. Pass every reference field to one IncludeReference call with an array before you call IncludeOnlyReference.Call IncludeReference before IncludeOnlyReference, not after. IncludeReference throws ArgumentException when a reference list exists.The API returns only the listed fields of each referenced entry. See Only Operator in the Content Delivery API reference.ExampleBasic usage: shape one reference fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .IncludeOnlyReference(new string[] { "title", "email" }, "author")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Get("author"));
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Several reference fields: list them in IncludeReference firstusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .IncludeReference(new string[] { "author", "category" })
        .IncludeOnlyReference(new string[] { "title", "email" }, "author")
        .IncludeOnlyReference(new string[] { "title" }, "category")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Get("category"));
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Field UIDs of the referenced entry to return.

UID of the reference field to expand.

## IncludeOwner

IncludeOwner requests the owner details of each entry in the response.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException on a second call on the same query, because the SDK stores the include_owner parameter once. See Options set once per query on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeOwner sets the include_owner URL query parameter and makes no request. Find, FindOne and Count send include_owner=True.ExampleBasic usage: include owner detailsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .IncludeOwner()
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Get("_owner"));
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeReference

IncludeReference returns the content of referenced entries in place of their UIDs.

```
Returns: Query. The same query, for chaining.
OverloadsIncludeReference(string filed_uid)IncludeReference(string[] filed_uids)ValidationA null or empty argument is not an error. IncludeReference adds nothing.Throws ArgumentException if the query already has a reference list, from an earlier IncludeReference, IncludeOnlyReference or IncludeExceptReference call, because the SDK stores the include[] parameter once. Pass every reference field in one call with the array overload.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeReference sets the include[] URL query parameter and makes no request. Find, FindOne and Count send one include[]=<field UID> pair per field.The parameter names keep the SDK's spelling, filed_uid and filed_uids, for named arguments.Without include[], the API returns only the UIDs of referenced entries. With it, the API returns their content. See Include Reference in the Content Delivery API reference.To limit the fields of a referenced entry, use the IncludeOnlyReference or IncludeExceptReference method after IncludeReference.To add the content type UID to each referenced entry, chain the IncludeReferenceContentTypeUID method.ExampleBasic usage: expand one reference fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .IncludeReference("author")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Get("author"));
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Array overload: expand several reference fieldsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .IncludeReference(new string[] { "author", "category" })
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Get("category"));
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID of the reference field to expand.

UIDs of the reference fields to expand.

## IncludeReferenceContentTypeUID

IncludeReferenceContentTypeUID adds the content type UID to each referenced entry in the response.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException on a second call on the same query, because the SDK stores the include_reference_content_type_uid parameter once. See Options set once per query on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeReferenceContentTypeUID sets the include_reference_content_type_uid URL query parameter and makes no request. Find, FindOne and Count send include_reference_content_type_uid=True.It affects only reference fields that the response expands. Pair it with the IncludeReference method.ExampleBasic usage: include content type UIDs of referencesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .IncludeReference("author")
        .IncludeReferenceContentTypeUID()
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Get("author"));
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeSchema

IncludeSchema requests the content type schema, with its global field schemas, in the response.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException on a second call on the same query, because the SDK stores the include_schema and include_global_field_schema parameters once. See Options set once per query on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeSchema sets two URL query parameters and makes no request. Find, FindOne and Count send include_schema=True and include_global_field_schema=True.Known issue: Find and FindOne return only the entries and the count, so the schema in the response does not reach your code. Call Fetch on client.ContentType("<CONTENT_TYPE_UID>") to read the schema. See the ContentType class page.ExampleBasic usage: request the schema with the entriesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .IncludeSchema()
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## LessThan

LessThan matches entries whose field value is less than the given value.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key or value is null, because the condition needs a field and a value to compare.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.LessThan does not check that value suits the field type.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. LessThan stores { "<key>": { "$lt": <value> } } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.The SDK serializes value with System.Text.Json, so a number goes as a JSON number and a string as a JSON string.The API returns the entries whose field value is less than value, not equal to it. See Less Than in the Content Delivery API reference.On a date field such as updated_at, pass the date as an ISO 8601 string, for example "2026-01-01".To bound one field on both sides, build each condition in its own query and combine them with the And method.ExampleBasic usage: compare a number fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .LessThan("price", 100)
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Date field: match entries updated before a dateusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .LessThan("updated_at", "2026-01-01")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID or dotted path of the field to filter.

Upper bound the field value must stay below.

## LessThanOrEqualTo

LessThanOrEqualTo matches entries whose field value is less than or equal to the given value.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key or value is null, because the condition needs a field and a value to compare.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.LessThanOrEqualTo does not check that value suits the field type.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. LessThanOrEqualTo stores { "<key>": { "$lte": <value> } } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.The SDK serializes value with System.Text.Json, so a number goes as a JSON number and a string as a JSON string.The API returns the entries whose field value is less than or equal to value. See Less Than Or Equal To in the Content Delivery API reference.On a date field such as updated_at, pass the date as an ISO 8601 string, for example "2026-01-01".To bound one field on both sides, build each condition in its own query and combine them with the And method.ExampleBasic usage: compare a number fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .LessThanOrEqualTo("price", 100)
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Date field: match entries updated on or before a dateusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .LessThanOrEqualTo("updated_at", "2026-01-01")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID or dotted path of the field to filter.

Upper bound the field value must not exceed.

## Limit

Limit caps the number of entries the response contains.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException on a second call on the same query, because the SDK stores the limit parameter once. See Options set once per query on the Query class page.Limit does not check the value. The SDK sends zero or a negative number as given.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Limit sets the limit URL query parameter and makes no request. Find and Count send it.Without Limit, the API returns the first 100 entries. See Pagination in the Content Delivery API reference.The API accepts positive integers only. For 0, an empty value, or a non-numeric value, it returns the default number of entries, not every match. See Limit in the Content Delivery API reference.The FindOne method replaces this value with 1.ExampleBasic usage: return at most ten entriesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Limit(10)
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Maximum number of entries to return.

## NotContainedIn

NotContainedIn matches entries whose field value equals none of the given values.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key or values is null, because the condition needs a field and a value to compare.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.NotContainedIn does not check the array length. The SDK sends an empty array as given.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. NotContainedIn copies values into a list, stores { "<key>": { "$nin": [ <values> ] } } in the query conditions, and makes no request. Find, FindOne and Count send the conditions as the query parameter.The SDK serializes each value with System.Text.Json, so numbers and strings keep their JSON types.The API returns the entries whose field value matches none of values. See Array Not-equals Operator in the Content Delivery API reference.To match a list of values, use the ContainedIn method.ExampleBasic usage: match a list of stringsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .NotContainedIn("color", new object[] { "Gold", "Black" })
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Number field: match a list of pricesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .NotContainedIn("price", new object[] { 101, 749 })
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID or dotted path of the field to filter.

Values the field must not equal.

## NotEqualTo

NotEqualTo matches entries whose field value does not equal the given value.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key or value is null, because the condition needs a field and a value to compare.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.NotEqualTo does not check that value suits the field type.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. NotEqualTo stores { "<key>": { "$ne": <value> } } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.The SDK serializes value with System.Text.Json, so a number goes as a JSON number and a string as a JSON string.The API returns the entries whose field value does not match value. See Not-equals Operator in the Content Delivery API reference.To exclude several values at once, use the NotContainedIn method.ExampleBasic usage: exclude one titleusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .NotEqualTo("title", "Home")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Number field: exclude one priceusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .NotEqualTo("price", 146)
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID or dotted path of the field to filter.

Value the field must differ from.

## NotExists

NotExists matches entries that have no value for the given field.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key is null, because the condition needs a field.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. NotExists stores { "<key>": { "$exists": false } } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.The API returns the entries in which the field does not exist. See Exists in the Content Delivery API reference.To match entries that have the field, use the Exists method.ExampleBasic usage: check a fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .NotExists("url")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Field inside a group: check a subfieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .NotExists("seo.meta_title")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID or dotted path of the field to filter.

## Only

Only returns only the listed top-level fields of each entry.

```
Returns: Query. The same query, for chaining.
ValidationA null or empty array is not an error. Only adds nothing.A second call on the same query is not an error. The SDK keeps the first list and ignores the second, without a warning. Pass every field in one call.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Only sets the only[BASE][] URL query parameter and makes no request. Find, FindOne and Count send one pair per field.BASE refers to the top-level fields of the entry. The API returns only the listed fields of each entry and leaves out the rest. See Only Operator in the Content Delivery API reference.To shape the fields of a referenced entry, use the IncludeOnlyReference method.ExampleBasic usage: return two fieldsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Only(new string[] { "title", "url" })
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Field UIDs to return.

## Or

Or matches entries that satisfy at least one condition in a list of sub-queries.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if queryObjects is null or empty, because there is nothing to combine.Throws QueryFilterException if the list holds a null item, because the SDK reads the conditions of each item.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Or stores { "$or": [ <conditions of each sub-query> ] } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.A second Or call replaces the first list. It does not throw.The SDK reads only the conditions of each sub-query. Their content type, locale, limit and other parameters have no effect.The SDK keeps a reference to each sub-query's conditions, not a copy. A condition you add to a sub-query before Find also reaches the request.Conditions on the main query outside the list still apply, so an entry must also satisfy them.The API returns the entries that satisfy at least one sub-query. See OR Operator in the Content Delivery API reference.To match entries that satisfy every sub-query, use the And method.ExampleBasic usage: match either of two valuesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;
using System.Collections.Generic;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Query goldQuery = client.ContentType("<CONTENT_TYPE_UID>").Query().Where("color", "Gold");
    Query blackQuery = client.ContentType("<CONTENT_TYPE_UID>").Query().Where("color", "Black");

    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Or(new List<Query> { goldQuery, blackQuery })
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Sub-queries whose conditions the API combines.

## ReferenceIn

ReferenceIn matches entries whose reference field values point to at least one entry that matches a sub-query.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key or query is null, because the condition needs a reference field and a sub-query.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. ReferenceIn stores { "<key>": { "$in_query": { <sub-query conditions> } } } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.The SDK reads only the conditions of the sub-query. Its content type, locale, limit and other parameters have no effect.The SDK keeps a reference to the sub-query conditions, not a copy. A condition you add to the sub-query before Find also reaches the request.The API returns the entries whose reference field points to an entry that satisfies the sub-query conditions. See Reference Search Equals in the Content Delivery API reference.When the reference field refers to more than one content type, add a _content_type_uid condition to the sub-query to name the referenced content type.To match entries whose references do not satisfy the sub-query, use the ReferenceNotIn method.ExampleBasic usage: filter by a field of the referenced entryusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // The SDK uses only the conditions of the sub-query
    Query authorQuery = client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Where("title", "John Doe");

    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .ReferenceIn("author", authorQuery)
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

UID of the reference field to filter.

Sub-query with conditions on the referenced entries.

## ReferenceNotIn

ReferenceNotIn matches entries whose reference field values do not point to an entry that matches a sub-query.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key or query is null, because the condition needs a reference field and a sub-query.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. ReferenceNotIn stores { "<key>": { "$nin_query": { <sub-query conditions> } } } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.The SDK reads only the conditions of the sub-query. Its content type, locale, limit and other parameters have no effect.The SDK keeps a reference to the sub-query conditions, not a copy. A condition you add to the sub-query before Find also reaches the request.The API returns the entries whose reference field does not point to an entry that satisfies the sub-query conditions. See Reference Search Not-equals in the Content Delivery API reference.When the reference field refers to more than one content type, add a _content_type_uid condition to the sub-query to name the referenced content type.To match entries whose references satisfy the sub-query, use the ReferenceIn method.ExampleBasic usage: filter by a field of the referenced entryusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // The SDK uses only the conditions of the sub-query
    Query authorQuery = client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Where("title", "John Doe");

    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .ReferenceNotIn("author", authorQuery)
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

UID of the reference field to filter.

Sub-query with conditions on the referenced entries.

## Regex

Regex matches entries whose field value matches a regular expression.

```
Returns: Query. The same query, for chaining.
OverloadsRegex(string key, string regex)Regex(string key, string regex, string modifiers)ValidationThrows QueryFilterException if key or regex is null, because the condition needs a field and a value to compare.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.Regex does not check the pattern syntax or the modifiers value. The SDK sends both as given.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Regex stores { "<key>": { "$regex": "<regex>" } } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.The three-argument overload adds "$options": "<modifiers>" to the same condition when modifiers is not null.The API returns the entries whose field value matches the pattern. See Search by Regex in the Content Delivery API reference.The SDK does not URL-encode the pattern, so a pattern that holds & or # changes the request URL. See Request URL encoding in the SDK-Wide Notes of the usage guide.ExampleBasic usage: match titles that start with a prefixusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Regex("title", "^Blog")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}All parameters: add a regex optionusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Regex("title", "^blog", "i")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID or dotted path of the field to filter.

Regular expression the field value must match.

Regex options, sent as $options. null sends none.

## RemoveHeader

RemoveHeader deletes a request header from the query.

```
Returns: void. This method returns nothing.
ValidationA null or empty key is not an error. RemoveHeader does nothing.A key the query does not hold is not an error. RemoveHeader does nothing.BehaviorClient-side only. RemoveHeader deletes the header from this query and makes no request.It removes headers that the SetHeader and Variant methods add on this query. It does not remove headers set on the client, such as the API key.RemoveHeader returns nothing, so it cannot sit inside a method chain. Call it on the query variable.ExampleBasic usage: replace a header valueusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Query query = client.ContentType("<CONTENT_TYPE_UID>").Query();
    query.SetHeader("x-request-id", "first-value");

    // Remove the header before setting a new value
    query.RemoveHeader("x-request-id");
    query.SetHeader("x-request-id", "second-value");

    ContentstackCollection<Entry> result = await query.Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the header to remove.

## RemoveQuery

RemoveQuery deletes the condition stored under the given field UID.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key is null, because the SDK looks the key up in the query conditions.A key with no stored condition is not an error. RemoveQuery leaves the query unchanged.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. RemoveQuery deletes the condition from the query conditions and makes no request.It removes conditions that the filter methods store, such as Where, GreaterThan, ContainedIn, ReferenceIn, And and Or.It does not remove URL query parameters such as limit, locale or those from the AddParam method.To replace a condition, call RemoveQuery with the field UID, then add the new condition. A second condition on the same field without RemoveQuery throws QueryFilterException.ExampleBasic usage: replace a condition on the same fieldusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Query query = client.ContentType("<CONTENT_TYPE_UID>").Query()
        .GreaterThan("price", 100);

    // Drop the first condition before adding another on the same field
    query.RemoveQuery("price").GreaterThan("price", 500);

    ContentstackCollection<Entry> result = await query.Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Field UID, or $and or $or, to remove.

## SetCachePolicy

SetCachePolicy records a cache policy on the query.

```
Returns: Query. The same query, for chaining.
ValidationThere is no client-side validation.BehaviorSetCachePolicy stores the value and makes no request. Find, FindOne and Count do not read it, so it has no effect on the request.The CachePolicy enum, in the Contentstack.Core.Internals namespace, has one member, NetworkOnly. Every request goes to the API, and the SDK does not cache responses.A second call replaces the first value. It does not throw.ExampleBasic usage: set the network-only policyusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .SetCachePolicy(CachePolicy.NetworkOnly)
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Cache policy to record.

## SetHeader

SetHeader adds a request header to the query.

```
Returns: void. This method returns nothing.
ValidationA null or empty key or value is not an error. SetHeader adds nothing.Throws ArgumentException if the query already holds a header named key, because the query stores each header once. Call the RemoveHeader method first to change a value.BehaviorClient-side only. SetHeader stores the header on this query and makes no request. Find, FindOne and Count send it.A header set on the query replaces a client-level header with the same name, for this query's requests only.SetHeader returns nothing, so it cannot sit inside a method chain. Call it on the query variable.ExampleBasic usage: add a custom headerusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Query query = client.ContentType("<CONTENT_TYPE_UID>").Query();
    query.SetHeader("x-request-id", "homepage-build");

    ContentstackCollection<Entry> result = await query.Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the header.

Value of the header.

## SetLocale

SetLocale sets the locale of the entries the query returns.

```
Returns: Query. The same query, for chaining.
ValidationThere is no client-side validation.A null or empty Locale is not an error. The SDK sends an empty locale parameter.An invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. SetLocale sets the locale URL query parameter and makes no request. Find, FindOne and Count send it.A second call replaces the first value. It does not throw.The API returns only the entries published in this locale. See Get all entries in the Content Delivery API reference.To fall back to another locale for entries not published in this one, chain the IncludeFallback method.ExampleBasic usage: fetch entries in a localeusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .SetLocale("<LOCALE>")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Locale code, such as en-us.

## Skip

Skip sets the number of matching entries the response skips, for pagination.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException on a second call on the same query, because the SDK stores the skip parameter once. See Options set once per query on the Query class page.Skip does not check the value. The SDK sends a negative number as given.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Skip sets the skip URL query parameter and makes no request. Find, FindOne and Count send it.The API skips that number of entries before it returns the next page. See Skip in the Content Delivery API reference.To page through results, pair Skip with the Limit method and build a new query for each page. See Pagination on the Query class page.ExampleBasic usage: read the second page of ten entriesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Skip(10)
        .Limit(10)
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Number of entries to skip.

## Variant

Variant returns the entries with the content of one or more entry variants applied.

```
Returns: Query. The same query, for chaining.
OverloadsVariant(string variant_header, string branch = null)Variant(List<string> variant_headers, string branch = null)ValidationA null or empty variant_header, or an empty list, is not an error. The SDK sends no x-cs-variant-uid header, so the API returns the base entries.Throws ArgumentNullException if variant_headers is null, because the SDK joins the list items.Throws ArgumentException on a second Variant call, or after a SetHeader call for x-cs-variant-uid or branch, because the query stores each header once. Call the RemoveHeader method for both headers first.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Variant makes no request. Find, FindOne and Count send the two headers it sets on the query:x-cs-variant-uid, holding the variant UID, or the list joined with commas.branch, holding the branch to read from.When branch is null, empty, or white space, the SDK uses the Branch set on the client options. When the client has no branch, the SDK sends main.The branch header from Variant replaces the client's branch for this query's requests only.The API accepts a variant alias in place of a variant UID. It applies up to five variants by default, and the first one in the list takes priority on the base entry fields. See Get all entry variants in the Content Delivery API reference.ExampleBasic usage: apply one variantusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Variant("<VARIANT_UID>")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}All parameters: apply a list of variants on a branchusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;
using System.Collections.Generic;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Variant(new List<string> { "<VARIANT_UID>" }, "<BRANCH>")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}One variant on a branchusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Variant("<VARIANT_UID>", "<BRANCH>")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Variant UID or variant alias.

Branch to read the variant from.

Variant UIDs or aliases, in priority order.

## Where

Where matches entries whose field equals the given value.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException if key or value is null, because the condition needs a field and a value to compare.Throws QueryFilterException if the query already holds a condition on key, because the SDK stores one condition per field. See How conditions combine on the Query class page.Where does not check that value suits the field type.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Where stores { "<key>": <value> } in the query conditions and makes no request. Find, FindOne and Count send the conditions as the query parameter.The SDK serializes value with System.Text.Json. A string, number or bool goes as that JSON type.A Dictionary<string, object> value goes as a JSON object, so Where can send any operator the API accepts, such as the taxonomy operators that have no dedicated method.The API returns the entries whose field value matches value. See Equals Operator in the Content Delivery API reference.To match a field inside a Group field, pass the dotted path, for example "seo.meta_title".A taxonomy condition takes the path taxonomies.<TAXONOMY_UID> as key and a term UID, or an operator object, as value. See Taxonomy in the Content Delivery API reference.ExampleBasic usage: match an exact titleusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Where("title", "Home")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Taxonomy: match entries tagged with a termusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Where("taxonomies.<TAXONOMY_UID>", "<TERM_UID>")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}Operator object: match a term and the terms below itusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;
using System.Collections.Generic;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .Where("taxonomies.<TAXONOMY_UID>", new Dictionary<string, object> { { "$eq_below", "<TERM_UID>" } })
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

UID or dotted path of the field to filter.

Value the field must equal.

## WhereTags

WhereTags filters entries by the tags assigned to them.

```
Returns: Query. The same query, for chaining.
ValidationA null or empty tags array is not an error. WhereTags adds nothing.Throws ArgumentException on a second call on the same query, because the SDK stores the tags parameter once. See Options set once per query on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. WhereTags stores the array as the tags URL query parameter and makes no request. Find, FindOne and Count send one tags=<tag> pair per array item.WhereTags writes a URL query parameter, not a condition in the query parameter. The RemoveQuery method does not remove it.Pass every tag in one call.ExampleBasic usage: filter entries by tagsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .WhereTags(new string[] { "featured", "summer" })
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Tags to filter entries by.

## includeEmbeddedItems

includeEmbeddedItems adds the entries and assets embedded in Rich Text Editor fields to the response.

```
Returns: Query. The same query, for chaining.
ValidationThrows QueryFilterException on a second call on the same query, because the SDK stores the include_embedded_items[] parameter once. See Options set once per query on the Query class page.Any other invalid value surfaces as a QueryFilterException when Find, FindOne or Count sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. includeEmbeddedItems sets the include_embedded_items[] URL query parameter and makes no request. Find, FindOne and Count send include_embedded_items[]=BASE.The API includes the first level of entries and assets embedded in Rich Text Editor fields under the _embedded_items key. See Get information on embedded RTE objects in the Content Delivery API reference.The method name starts with a lowercase i. C# names are case-sensitive, so IncludeEmbeddedItems does not compile on a query.ExampleBasic usage: include embedded itemsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.ContentType("<CONTENT_TYPE_UID>").Query()
        .includeEmbeddedItems()
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Get("_embedded_items"));
    }
}
catch (ContentstackException e)
{
    // Thrown when the query is invalid or the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## Query

Read and write. UID of the content type the query reads entries from.

Read. The SDK does not set this property, so it reads null.

## Query | .NET Delivery SDK | Contentstack

The Query class in the .NET Delivery SDK filters, sorts, and pages the entries of a content type, then sends the request and returns the matching entries.

## Taxonomy

[Taxonomy](/docs/headless-cms/about-taxonomy) organizes the content of a stack into a hierarchy of terms that you tag entries with. Use the Taxonomy class for the four tasks below:

*   list the taxonomies published to an environment
*   read one published taxonomy by its UID
*   reach the terms of that taxonomy
*   filter entries by the terms they carry

client.Taxonomies() and client.Taxonomies(uid) on [ContentstackClient](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/contentstackclient) return a Taxonomy:

Name

Type

Description

uid

string

UID of the taxonomy to read. Omit it to list taxonomies or filter entries.

Taxonomy inherits from [Query](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/query), so every Query method is also available on a Taxonomy. The pages below cover only the methods that Taxonomy declares itself. The Query class page documents the inherited filters, for example Where, Exists, Or, And, Limit and IncludeCount.

## Above

Above matches entries tagged with the ancestors of a term, excluding the term itself.

```
Returns: Taxonomy. The same taxonomy, for chaining.
ValidationThrows NullReferenceException if key or value is null, because the condition needs both a field path and a term.Throws TaxonomyException if the instance already holds a condition on key, because each field path holds one condition. Use the inherited Or or And method to combine two conditions on one field.There is no other client-side validation. Above stores an empty key or an unknown term UID as given.An invalid value surfaces as a ContentstackException (or a subclass) when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Above stores the condition { "$above": value } under key and makes no request.The match excludes the named term. An entry tagged only with that term does not match. Use the EqualAndAbove method to include it.Sends no levels value, so the API matches ancestors up to 10 levels above the term (Above Operator). The Hierarchy levels note on the Taxonomy class page gives the Where workaround that sets the levels.Chaining Above makes the following Find call GET /taxonomies/entries, so Find returns entries instead of taxonomies.ExampleBasic usage: match the ancestors of a termusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.Taxonomies()
        .Above("taxonomies.<TAXONOMY_UID>", "<TERM_UID>")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}Edge case: a second condition on the same field throwsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Taxonomy taxonomy = client.Taxonomies().Above("taxonomies.<TAXONOMY_UID>", "<TERM_UID>");

    // The field path already holds the Above condition, so this call throws
    taxonomy.EqualAndBelow("taxonomies.<TAXONOMY_UID>", "<TERM_UID>");
}
catch (TaxonomyException e)
{
    // Thrown when the field path already holds a condition
    Console.WriteLine(e.Message);
}
```

Taxonomy field path, for example taxonomies.color.

UID of the term whose ancestors to match.

## AddParam

AddParam adds one query parameter to Fetch and to the taxonomy list.

```
Returns: Taxonomy. The same taxonomy, for chaining.
ValidationThrows ArgumentNullException if key is null, because the SDK stores parameters in a dictionary keyed by name.There is no other client-side validation. A null value sends the parameter with an empty value.An invalid value surfaces as a ContentstackException (or a subclass) when Fetch or Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. AddParam stores the pair and makes no request. A second call with the same key replaces the first value.Fetch and the taxonomy list from Find send the pair.Use it for the parameters this class has no method for, for example skip and limit, which page the taxonomy list (Get all taxonomies).Replaces the Query method of the same name. The entry filter does not send this pair. The Known issue notes on the Taxonomy class page give the workaround for the entry filter.ExampleBasic usage: page through the taxonomy listusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<JsonObject> result = await client.Taxonomies()
        .AddParam("skip", "0")
        .AddParam("limit", "5")
        .Find<JsonObject>();
    foreach (JsonObject taxonomy in result)
    {
        Console.WriteLine(taxonomy["uid"]);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the query parameter, for example limit.

Value of the query parameter.

## Below

Below matches entries tagged with the descendants of a term, excluding the term itself.

```
Returns: Taxonomy. The same taxonomy, for chaining.
ValidationThrows NullReferenceException if key or value is null, because the condition needs both a field path and a term.Throws TaxonomyException if the instance already holds a condition on key, because each field path holds one condition. Use the inherited Or or And method to combine two conditions on one field.There is no other client-side validation. Below stores an empty key or an unknown term UID as given.An invalid value surfaces as a ContentstackException (or a subclass) when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Below stores the condition { "$below": value } under key and makes no request.The match excludes the named term. An entry tagged only with that term does not match. Use the EqualAndBelow method to include it.Sends no levels value, so the API matches descendants up to 10 levels below the term (Below Operator). The Hierarchy levels note on the Taxonomy class page gives the Where workaround that sets the levels.Chaining Below makes the following Find call GET /taxonomies/entries, so Find returns entries instead of taxonomies.ExampleBasic usage: match the descendants of a termusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.Taxonomies()
        .Below("taxonomies.<TAXONOMY_UID>", "<TERM_UID>")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Taxonomy field path, for example taxonomies.color.

UID of the term whose descendants to match.

## EqualAndAbove

EqualAndAbove matches entries tagged with a term or any of its ancestors.

```
Returns: Taxonomy. The same taxonomy, for chaining.
ValidationThrows NullReferenceException if key or value is null, because the condition needs both a field path and a term.Throws TaxonomyException if the instance already holds a condition on key, because each field path holds one condition. Use the inherited Or or And method to combine two conditions on one field.There is no other client-side validation. EqualAndAbove stores an empty key or an unknown term UID as given.An invalid value surfaces as a ContentstackException (or a subclass) when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. EqualAndAbove stores the condition { "$eq_above": value } under key and makes no request.The match includes the named term. Use the Above method to match the ancestors only.Sends no levels value, so the API matches ancestors up to 10 levels above the term (Equal and Above Operator). The Hierarchy levels note on the Taxonomy class page gives the Where workaround that sets the levels.Chaining EqualAndAbove makes the following Find call GET /taxonomies/entries, so Find returns entries instead of taxonomies.ExampleBasic usage: match a term and its ancestorsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.Taxonomies()
        .EqualAndAbove("taxonomies.<TAXONOMY_UID>", "<TERM_UID>")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Taxonomy field path, for example taxonomies.color.

UID of the term to match, together with its ancestors.

## EqualAndBelow

EqualAndBelow matches entries tagged with a term or any of its descendants.

```
Returns: Taxonomy. The same taxonomy, for chaining.
ValidationThrows NullReferenceException if key or value is null, because the condition needs both a field path and a term.Throws TaxonomyException if the instance already holds a condition on key, because each field path holds one condition. Use the inherited Or or And method to combine two conditions on one field.There is no other client-side validation. EqualAndBelow stores an empty key or an unknown term UID as given.An invalid value surfaces as a ContentstackException (or a subclass) when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. EqualAndBelow stores the condition { "$eq_below": value } under key and makes no request.The match includes the named term. Use the Below method to match the descendants only.Sends no levels value, so the API matches descendants up to 10 levels below the term (Equal and Below Operator). The Hierarchy levels note on the Taxonomy class page gives the Where workaround that sets the levels.Chaining EqualAndBelow makes the following Find call GET /taxonomies/entries, so Find returns entries instead of taxonomies.ExampleBasic usage: match a term and its descendantsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<Entry> result = await client.Taxonomies()
        .EqualAndBelow("taxonomies.<TAXONOMY_UID>", "<TERM_UID>")
        .Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Taxonomy field path, for example taxonomies.color.

UID of the term to match, together with its descendants.

## Fetch

Fetch reads one published taxonomy by its UID.

```
Returns: Task<T>. The requested taxonomy.
ValidationThrows TaxonomyException if the instance holds no taxonomy UID, because Fetch reads one specific taxonomy. Create the instance with client.Taxonomies("<TAXONOMY_UID>").Throws TaxonomyException if the request fails, for example for an unknown taxonomy UID.Throws TaxonomyException with ErrorCode 0 if the response does not deserialize into T.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorCalls GET /taxonomies/{taxonomy_uid} (Get a single taxonomy) and makes one HTTP request per call.Deserializes the taxonomy object of the response into T and returns it. When the response has no taxonomy key, the SDK deserializes the whole response body into T.Sends the values from SetLocale, IncludeFallback and AddParam. The inherited Query methods, for example IncludeBranch, do not reach this request.With a locale and no fallback, the API returns a 404 error for a taxonomy that has no localization in that locale. Chain IncludeFallback to receive the taxonomy through the locale fallback hierarchy of the branch.Does not return the terms of the taxonomy. Use the Terms method to list them.ExampleBasic usage: read a taxonomy into a model classusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    TaxonomyInfo taxonomy = await client.Taxonomies("<TAXONOMY_UID>").Fetch<TaxonomyInfo>();
    Console.WriteLine($"{taxonomy.Name}: {taxonomy.Description}");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TaxonomyInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
}Localized: read a taxonomy in a locale, with fallbackusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject taxonomy = await client.Taxonomies("<TAXONOMY_UID>")
        .SetLocale("<LOCALE>")
        .IncludeFallback()
        .Fetch<JsonObject>();
    Console.WriteLine($"{taxonomy["name"]} ({taxonomy["locale"]})");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## Find

Find lists the taxonomies published to the environment, or returns the entries that match the filters chained before it.

```
Returns: Task<ContentstackCollection<T>>. The published taxonomies, or the entries that match the filters.
ValidationThrows TaxonomyException if the instance holds a taxonomy UID, because Find works across all taxonomies. Create the instance with client.Taxonomies() instead. The check applies even when you chain a filter first.When you list taxonomies, Find throws TaxonomyException if the request fails or if the response does not deserialize into T.When you filter entries, Find throws QueryFilterException if the request fails, because the entry filter runs through the inherited Query pipeline.Both exceptions inherit from ContentstackException. Catch ContentstackException to handle either path.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorFind selects one of the two endpoints below from what you chain before it:With no filter, it calls GET /taxonomies (Get all taxonomies) and reads the items from the taxonomies array of the response.After any filter, it calls GET /taxonomies/entries (Get all entries with defined taxonomies) and reads the items from the entries array. A filter is one of the four hierarchy filters on this class, or an inherited filter such as Exists or Where.Makes one HTTP request per call.The two paths read different query parameters:The taxonomy list sends the values from SetLocale, IncludeFallback and AddParam.The entry filter sends the values from the inherited Query methods, for example Limit, Skip and IncludeCount. The Known issue notes on the Taxonomy class page cover the gaps between the two.Does not page through results. Each call returns the one page of results that the API sends back.To page the taxonomy list, send skip and limit through AddParam.To page the entry filter, call the inherited Skip and Limit methods.Count on the result holds a total only when the response carries count. Skip and Limit on the result stay 0.ExampleBasic usage: list the published taxonomiesusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<TaxonomyInfo> result = await client.Taxonomies().Find<TaxonomyInfo>();
    foreach (TaxonomyInfo taxonomy in result)
    {
        Console.WriteLine($"{taxonomy.Uid}: {taxonomy.Name}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TaxonomyInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
}Pagination: page through the taxonomy listusing System;
using System.Linq;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // The taxonomy list reads skip and limit only through AddParam
    ContentstackCollection<JsonObject> page = await client.Taxonomies()
        .AddParam("skip", "10")
        .AddParam("limit", "10")
        .Find<JsonObject>();
    Console.WriteLine($"This page holds {page.Items.Count()} taxonomies");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}Filter entries: find entries by term, 10 at a timeusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Taxonomy taxonomy = client.Taxonomies().EqualAndBelow("taxonomies.<TAXONOMY_UID>", "<TERM_UID>");

    // The entry filter reads the inherited Query methods
    taxonomy.Skip(0);
    taxonomy.Limit(10);

    ContentstackCollection<Entry> result = await taxonomy.Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}Edge case: filter entries in a localeusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    // Taxonomy.SetLocale does not reach the entry filter, so call Query.SetLocale through a Query variable
    Query query = client.Taxonomies().Below("taxonomies.<TAXONOMY_UID>", "<TERM_UID>");
    query.SetLocale("<LOCALE>");

    ContentstackCollection<Entry> result = await query.Find<Entry>();
    foreach (Entry entry in result)
    {
        Console.WriteLine(entry.Title);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## IncludeFallback

IncludeFallback returns taxonomies through the locale fallback hierarchy of the branch when they have no localization in the requested locale.

```
Returns: Taxonomy. The same taxonomy, for chaining.
ValidationThere is no client-side validation.An invalid value surfaces as a ContentstackException (or a subclass) when Fetch or Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeFallback stores include_fallback=true and makes no request. No method removes it, so build a new instance to send a request without it.Fetch and the taxonomy list from Find send the value.The API applies it in two ways:On Fetch, a taxonomy with no localization in the requested locale returns through the fallback hierarchy instead of a 404 error (Get a single taxonomy).On the taxonomy list, the response also includes the taxonomies that have no localization in the requested locale. Each taxonomy's locale field shows the locale it came from (Get all taxonomies).Works with or without SetLocale.To use the fallback hierarchy of a branch other than main, set Branch on ContentstackOptions, so the SDK sends the branch header.Replaces the Query method of the same name. The entry filter does not send this value. The Known issue notes on the Taxonomy class page give the workaround for the entry filter.ExampleBasic usage: read a taxonomy with locale fallbackusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject taxonomy = await client.Taxonomies("<TAXONOMY_UID>")
        .SetLocale("<LOCALE>")
        .IncludeFallback()
        .Fetch<JsonObject>();
    Console.WriteLine($"{taxonomy["name"]} ({taxonomy["locale"]})");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## SetLocale

SetLocale sets the locale that Fetch and the taxonomy list request the taxonomy names in.

```
Returns: Taxonomy. The same taxonomy, for chaining.
ValidationThere is no client-side validation of the locale code.A null or empty locale changes nothing. SetLocale keeps any locale set earlier and does not throw.An invalid value surfaces as a ContentstackException (or a subclass) when Fetch or Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. SetLocale stores the locale query parameter and makes no request. A second call replaces the first value.Fetch and the taxonomy list from Find send the value (Get a single taxonomy, Get all taxonomies).Without IncludeFallback, the API returns only the values localized in this locale. Fetch returns a 404 error for a taxonomy with no localization in it.Replaces the Query method of the same name. The entry filter does not send this value. The Known issue notes on the Taxonomy class page give the workaround for the entry filter.Does not reach the terms. The Term and Terms methods create objects with their own SetLocale.ExampleBasic usage: read a taxonomy in a localeusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject taxonomy = await client.Taxonomies("<TAXONOMY_UID>")
        .SetLocale("<LOCALE>")
        .Fetch<JsonObject>();
    Console.WriteLine(taxonomy["name"]);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}List taxonomies: request localized namesusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<JsonObject> result = await client.Taxonomies()
        .SetLocale("<LOCALE>")
        .Find<JsonObject>();
    foreach (JsonObject taxonomy in result)
    {
        Console.WriteLine(taxonomy["name"]);
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

Locale code, for example fr-fr.

## Term

Term creates a [Term](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/term) object for one term of this taxonomy.

```
Returns: Term. A new term object.
ValidationThrows TaxonomyException if the instance holds no taxonomy UID, because a term belongs to one specific taxonomy. Create the instance with client.Taxonomies("<TAXONOMY_UID>").Throws TaxonomyException if termUid is null or empty, because the term needs a UID for its request path.There is no other client-side validation. An unknown term UID surfaces as a TaxonomyException when a request method on the Term sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Term makes no request. Call Fetch, Locales, Ancestors or Descendants on the returned object to send one.Passes only the client, the taxonomy UID and termUid to the new object. Values from SetLocale, IncludeFallback and AddParam on the taxonomy do not reach the term. Set them on the Term itself.Each call returns a new Term with no query parameters.ExampleBasic usage: read one term of a taxonomyusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    Term term = client.Taxonomies("<TAXONOMY_UID>").Term("<TERM_UID>");
    TermInfo result = await term.SetLocale("<LOCALE>").Fetch<TermInfo>();
    Console.WriteLine($"{result.Uid}: {result.Name}");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
}
```

UID of the term to work with.

## Terms

Terms creates a [TermQuery](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/termquery) object that lists the published terms of this taxonomy.

```
Returns: TermQuery. A new term query object.
ValidationThrows TaxonomyException if the instance holds no taxonomy UID, because the terms belong to one specific taxonomy. Create the instance with client.Taxonomies("<TAXONOMY_UID>").There is no other client-side validation. An unknown taxonomy UID surfaces as a TaxonomyException when Find on the TermQuery sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Terms makes no request. Call Find on the returned object to send one.Passes only the client and the taxonomy UID to the new object. Values from SetLocale, IncludeFallback and AddParam on the taxonomy do not reach the term query. Set them on the TermQuery itself.Each call returns a new TermQuery with no query parameters.ExampleBasic usage: list the terms of a taxonomyusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    TermQuery terms = client.Taxonomies("<TAXONOMY_UID>").Terms();
    ContentstackCollection<TermInfo> result = await terms.Limit(20).Find<TermInfo>();
    foreach (TermInfo term in result)
    {
        Console.WriteLine($"{term.Uid}: {term.Name}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
}
```

## Taxonomy | .NET Delivery SDK | Contentstack

The Taxonomy class in the .NET Delivery SDK lists published taxonomies, fetches one taxonomy, reaches its terms, and filters entries by taxonomy terms.

## TermQuery

TermQuery lists the published terms of one [taxonomy](/docs/headless-cms/about-taxonomy). Use it to read the term hierarchy of a taxonomy, in a locale and one page at a time.

TermQuery has no public constructor. The [Terms](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/taxonomy#taxonomy-terms) method on a Taxonomy supplies the taxonomy UID below and returns a TermQuery:

Name

Type

Description

taxonomyUid

string

UID of the taxonomy whose terms to list.

client.Taxonomies("<TAXONOMY\_UID>").Terms() throws TaxonomyException (namespace Contentstack.Core.Internals) if the taxonomy has no UID. To read one term, use the [Term](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/taxonomy#taxonomy-term) method, which returns a [Term](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/term).

## AddParam

AddParam adds one query parameter to Find.

```
Returns: TermQuery. The same term query, for chaining.
ValidationThrows ArgumentNullException if key is null, because the SDK stores parameters in a dictionary keyed by name.There is no other client-side validation. A null value sends the parameter with an empty value.An invalid value surfaces as a ContentstackException (or a subclass) when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. AddParam stores the pair and makes no request. A second call with the same key replaces the first value, including a value from another modifier such as Limit.Find sends the value.Use it for a parameter that has no method on this class.ExampleBasic usage: send a parameter by nameusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<JsonObject> terms = await client.Taxonomies("<TAXONOMY_UID>")
        .Terms()
        .AddParam("depth", "1")
        .Find<JsonObject>();
    foreach (JsonObject term in terms)
    {
        Console.WriteLine(term["uid"]);
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the query parameter, for example depth.

Value of the query parameter.

## Depth

Depth sets the depth of the term hierarchy that Find retrieves.

```
Returns: TermQuery. The same term query, for chaining.
ValidationThere is no client-side validation. Depth stores zero or a negative number as given.An invalid value surfaces as a ContentstackException (or a subclass) when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Depth stores the depth query parameter and makes no request. A second call replaces the first value.Find sends the value (Get all terms).Without Depth, the SDK sends no depth value and the API applies its own.ExampleBasic usage: list the terms two levels deepusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<TermInfo> terms = await client.Taxonomies("<TAXONOMY_UID>")
        .Terms()
        .Depth(2)
        .Find<TermInfo>();
    foreach (TermInfo term in terms)
    {
        Console.WriteLine($"{term.Uid}: {term.Name}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
}
```

Number of hierarchy levels to retrieve.

## Find

Find lists the published terms of the taxonomy.

```
Returns: Task<ContentstackCollection<T>>. The matching terms.
ValidationThere is no client-side validation. The Terms method already rejected an instance without a taxonomy UID.Throws TaxonomyException if the request fails, for example for an unknown taxonomy UID.Throws TaxonomyException with ErrorCode 0 if a term in the response does not deserialize into T.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorCalls GET /taxonomies/{taxonomy_uid}/terms (Get all terms) and makes one HTTP request per call.Deserializes each item of the terms array of the response into T. Items on the result holds them, and the result is enumerable.Sends every query parameter stored on the instance, from SetLocale, IncludeFallback, Depth, Skip, Limit, IncludeCount, IncludeBranch and AddParam.Does not page automatically. Each call returns the one page of terms that the API sends back. Combine Skip and Limit to request the next page.Count on the result holds a total only when the response carries count. Skip and Limit on the result stay 0, so track the page position in your own code.ExampleBasic usage: list the terms of a taxonomyusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<TermInfo> terms = await client.Taxonomies("<TAXONOMY_UID>").Terms().Find<TermInfo>();
    foreach (TermInfo term in terms)
    {
        Console.WriteLine($"{term.Uid}: {term.Name}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
}Pagination: read every page of termsusing System;
using System.Linq;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    const int pageSize = 50;
    int skip = 0;
    while (true)
    {
        ContentstackCollection<JsonObject> page = await client.Taxonomies("<TAXONOMY_UID>")
            .Terms()
            .Skip(skip)
            .Limit(pageSize)
            .Find<JsonObject>();
        foreach (JsonObject term in page)
        {
            Console.WriteLine(term["uid"]);
        }

        // A short page is the last page
        if (page.Items.Count() < pageSize)
        {
            break;
        }
        skip += pageSize;
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## IncludeBranch

IncludeBranch requests the branch information of each term by sending include\_branch=true.

```
Returns: TermQuery. The same term query, for chaining.
ValidationThere is no client-side validation.An invalid value surfaces as a ContentstackException (or a subclass) when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeBranch stores include_branch=true and makes no request. No method removes it, so build a new instance to send a request without it.Find sends the value.Does not choose the branch. The Branch option on ContentstackOptions sets the branch the SDK reads from.ExampleBasic usage: list terms with their branch informationusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<JsonObject> terms = await client.Taxonomies("<TAXONOMY_UID>")
        .Terms()
        .IncludeBranch()
        .Find<JsonObject>();
    foreach (JsonObject term in terms)
    {
        Console.WriteLine($"{term["uid"]}: {term["_branch"]}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeCount

IncludeCount requests the total number of terms by sending include\_count=true.

```
Returns: TermQuery. The same term query, for chaining.
ValidationThere is no client-side validation.An invalid value surfaces as a ContentstackException (or a subclass) when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeCount stores include_count=true and makes no request. No method removes it, so build a new instance to send a request without it.Find sends the value.Count on the result of Find holds the total when the response carries count. Otherwise Count stays 0.ExampleBasic usage: read the total number of termsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<TermInfo> terms = await client.Taxonomies("<TAXONOMY_UID>")
        .Terms()
        .IncludeCount()
        .Limit(10)
        .Find<TermInfo>();
    Console.WriteLine($"Total terms: {terms.Count}");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
}
```

## IncludeFallback

IncludeFallback adds the terms that have no localization in the requested locale, through the locale fallback hierarchy of the branch.

```
Returns: TermQuery. The same term query, for chaining.
ValidationThere is no client-side validation.An invalid value surfaces as a ContentstackException (or a subclass) when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeFallback stores include_fallback=true and makes no request. No method removes it, so build a new instance to send a request without it.Find sends the value.The API also returns the terms that have no localization in the requested locale. Each term's locale field shows the locale it came from (Get all terms).Works with or without SetLocale.To use the fallback hierarchy of a branch other than main, set Branch on ContentstackOptions, so the SDK sends the branch header.ExampleBasic usage: list the terms in a locale, with fallbackusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<TermInfo> terms = await client.Taxonomies("<TAXONOMY_UID>")
        .Terms()
        .SetLocale("<LOCALE>")
        .IncludeFallback()
        .Find<TermInfo>();
    foreach (TermInfo term in terms)
    {
        Console.WriteLine($"{term.Name} ({term.Locale})");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
    public string Locale { get; set; }
}
```

## Limit

Limit caps the number of terms that Find returns.

```
Returns: TermQuery. The same term query, for chaining.
ValidationThere is no client-side validation. Limit stores zero or a negative number as given.An invalid value surfaces as a ContentstackException (or a subclass) when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Limit stores the limit query parameter and makes no request. A second call replaces the first value.Find sends the value (Get all terms).Without Limit, the SDK sends no limit value and the API applies its own page size.Combine it with Skip to page through the terms.ExampleBasic usage: return at most five termsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<TermInfo> terms = await client.Taxonomies("<TAXONOMY_UID>")
        .Terms()
        .Limit(5)
        .Find<TermInfo>();
    foreach (TermInfo term in terms)
    {
        Console.WriteLine($"{term.Uid}: {term.Name}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
}
```

Maximum number of terms to return.

## SetLocale

SetLocale sets the locale that Find returns the term names in.

```
Returns: TermQuery. The same term query, for chaining.
ValidationThere is no client-side validation of the locale code.A null or empty locale changes nothing. SetLocale keeps any locale set earlier and does not throw.An invalid value surfaces as a ContentstackException (or a subclass) when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. SetLocale stores the locale query parameter and makes no request. A second call replaces the first value.Find sends the value (Get all terms).Without IncludeFallback, the API returns only the terms localized in this locale.A locale set on the Taxonomy does not reach the term query. Set it on the TermQuery itself.ExampleBasic usage: list the terms in a localeusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<TermInfo> terms = await client.Taxonomies("<TAXONOMY_UID>")
        .Terms()
        .SetLocale("<LOCALE>")
        .Find<TermInfo>();
    foreach (TermInfo term in terms)
    {
        Console.WriteLine($"{term.Name} ({term.Locale})");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
    public string Locale { get; set; }
}
```

Locale code, for example fr-fr.

## Skip

Skip skips a number of terms, so Find returns a later page.

```
Returns: TermQuery. The same term query, for chaining.
ValidationThere is no client-side validation. Skip stores a negative number as given.An invalid value surfaces as a ContentstackException (or a subclass) when Find sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Skip stores the skip query parameter and makes no request. A second call replaces the first value.Find sends the value (Get all terms).Combine it with Limit to page through the terms. The Find page shows a loop that reads every page.ExampleBasic usage: read the second page of 10 termsusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    ContentstackCollection<TermInfo> terms = await client.Taxonomies("<TAXONOMY_UID>")
        .Terms()
        .Skip(10)
        .Limit(10)
        .Find<TermInfo>();
    foreach (TermInfo term in terms)
    {
        Console.WriteLine($"{term.Uid}: {term.Name}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
}
```

Number of terms to skip.

## TermQuery | .NET Delivery SDK | Contentstack

The TermQuery class in the .NET Delivery SDK lists the published terms of one taxonomy, with locale, depth and pagination options.

## Term

A term is one node in the hierarchy of a [taxonomy](/docs/headless-cms/about-taxonomy). Use the Term class for the three tasks below:

*   read one published term by its UID
*   list the localized versions of that term
*   retrieve the ancestors or the descendants of that term

Term has no public constructor. The [Term](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/taxonomy#taxonomy-term) method on a Taxonomy supplies both UIDs below and returns a Term:

Name

Type

Description

taxonomyUid

string

UID of the taxonomy that holds the term.

termUid

string

UID of the term.

client.Taxonomies("<TAXONOMY\_UID>").Term("<TERM\_UID>") throws TaxonomyException (namespace Contentstack.Core.Internals) if the taxonomy has no UID or termUid is null or empty. To list several terms, use the [Terms](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/taxonomy#taxonomy-terms) method, which returns a [TermQuery](/docs/developers/sdks/content-delivery-sdk/dot-net/reference/termquery).

## AddParam

AddParam adds one query parameter to the term requests.

```
Returns: Term. The same term, for chaining.
ValidationThrows ArgumentNullException if key is null, because the SDK stores parameters in a dictionary keyed by name.There is no other client-side validation. A null value sends the parameter with an empty value.An invalid value surfaces as a ContentstackException (or a subclass) when Fetch, Ancestors or Descendants sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. AddParam stores the pair and makes no request. A second call with the same key replaces the first value, including a value from SetLocale or Depth.Fetch, Ancestors and Descendants send the value. Locales does not.Use it for the parameters this class has no method for, for example skip and limit. They page the results of Ancestors and Descendants (Get descendants of a term).ExampleBasic usage: page through the descendants of a termusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonArray descendants = await client.Taxonomies("<TAXONOMY_UID>")
        .Term("<TERM_UID>")
        .AddParam("skip", "20")
        .AddParam("limit", "20")
        .Descendants<JsonArray>();
    Console.WriteLine($"Descendants on this page: {descendants.Count}");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Name of the query parameter, for example limit.

Value of the query parameter.

## Ancestors

Ancestors retrieves the terms above this one in the taxonomy hierarchy, up to the root.

```
Returns: Task<T>. The ancestor terms of the term.
ValidationThere is no client-side validation.Throws TaxonomyException if the request fails, for example for an unknown taxonomy UID or term UID.Throws TaxonomyException with ErrorCode 0 if the response does not deserialize into T. A T that holds a single object, for example a model class, fails this way, because the SDK reads an array.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorCalls GET /taxonomies/{taxonomy_uid}/terms/{term_uid}/ancestors (Get ancestors of a term) and makes one HTTP request per call.Deserializes the terms array of the response into T and returns it.Sends every query parameter stored on the instance, from SetLocale, IncludeFallback, Depth, IncludeBranch and AddParam.Returns the ancestors in the locale the term resolves to. When the term falls back to another locale, its ancestors come back in that locale too.Does not return the term itself. Use the Fetch method to read it.LimitationsDoes not filter entries. To match entries tagged with a term or its ancestors, use the EqualAndAbove method on a Taxonomy.ExampleBasic usage: list the ancestors of a termusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    List<TermInfo> ancestors = await client.Taxonomies("<TAXONOMY_UID>")
        .Term("<TERM_UID>")
        .Ancestors<List<TermInfo>>();
    foreach (TermInfo ancestor in ancestors)
    {
        Console.WriteLine($"{ancestor.Uid}: {ancestor.Name}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
}Localized: list the ancestors in a locale, with fallbackusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonArray ancestors = await client.Taxonomies("<TAXONOMY_UID>")
        .Term("<TERM_UID>")
        .SetLocale("<LOCALE>")
        .IncludeFallback()
        .Ancestors<JsonArray>();
    foreach (JsonNode ancestor in ancestors)
    {
        Console.WriteLine($"{ancestor["name"]} ({ancestor["locale"]})");
    }
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## Depth

Depth sets the depth of the term hierarchy that the term requests retrieve.

```
Returns: Term. The same term, for chaining.
ValidationThere is no client-side validation. Depth stores zero or a negative number as given.An invalid value surfaces as a ContentstackException (or a subclass) when Fetch, Ancestors or Descendants sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. Depth stores the depth query parameter and makes no request. A second call replaces the first value.Fetch, Ancestors and Descendants send the value. Locales does not.Without Depth, the SDK sends no depth value and the API applies its own (Get descendants of a term).The value persists on the instance, so a depth you set for Descendants also reaches a later Fetch or Ancestors call on the same Term.ExampleBasic usage: list two levels of descendantsusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    List<TermInfo> descendants = await client.Taxonomies("<TAXONOMY_UID>")
        .Term("<TERM_UID>")
        .Depth(2)
        .Descendants<List<TermInfo>>();
    foreach (TermInfo descendant in descendants)
    {
        Console.WriteLine($"{descendant.Uid}: {descendant.Name}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
}
```

Number of hierarchy levels to retrieve.

## Descendants

Descendants retrieves the terms below this one in the taxonomy hierarchy.

```
Returns: Task<T>. The descendant terms of the term.
ValidationThere is no client-side validation.Throws TaxonomyException if the request fails, for example for an unknown taxonomy UID or term UID.Throws TaxonomyException with ErrorCode 0 if the response does not deserialize into T. A T that holds a single object, for example a model class, fails this way, because the SDK reads an array.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorCalls GET /taxonomies/{taxonomy_uid}/terms/{term_uid}/descendants (Get descendants of a term) and makes one HTTP request per call.Deserializes the terms array of the response into T and returns it.Sends every query parameter stored on the instance, from SetLocale, IncludeFallback, Depth, IncludeBranch and AddParam.Chain Depth to set the depth of the hierarchy the API retrieves. Without it, the SDK sends no depth value and the API applies its own.With IncludeFallback, the API also returns the descendants that have no localization in the requested locale, through the locale fallback hierarchy of the branch.Does not page automatically. Send skip and limit through AddParam to page through a large set.LimitationsDoes not filter entries. To match entries tagged with a term or its descendants, use the EqualAndBelow method on a Taxonomy.ExampleBasic usage: list the descendants of a termusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    List<TermInfo> descendants = await client.Taxonomies("<TAXONOMY_UID>")
        .Term("<TERM_UID>")
        .Descendants<List<TermInfo>>();
    foreach (TermInfo descendant in descendants)
    {
        Console.WriteLine($"{descendant.Uid}: {descendant.Name}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
}Depth and paging: list two levels of descendants, 20 at a timeusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonArray descendants = await client.Taxonomies("<TAXONOMY_UID>")
        .Term("<TERM_UID>")
        .Depth(2)
        .AddParam("skip", "0")
        .AddParam("limit", "20")
        .Descendants<JsonArray>();
    Console.WriteLine($"Descendants on this page: {descendants.Count}");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## Fetch

Fetch reads one published term by its UID.

```
Returns: Task<T>. The requested term.
ValidationThere is no client-side validation. The Term method already rejected a null or empty term UID.Throws TaxonomyException if the request fails, for example for an unknown taxonomy UID or term UID.Throws TaxonomyException with ErrorCode 0 if the response does not deserialize into T.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorCalls GET /taxonomies/{taxonomy_uid}/terms/{term_uid} (Get a single term) and makes one HTTP request per call.Deserializes the term object of the response into T and returns it.Sends every query parameter stored on the instance, from SetLocale, IncludeFallback, Depth, IncludeBranch and AddParam.With a locale and no fallback, the API returns a 404 error for a term that has no localization in that locale. Chain IncludeFallback to receive the term through the locale fallback hierarchy of the branch.Does not return the ancestors or descendants of the term. Use the Ancestors or Descendants method.ExampleBasic usage: read a term into a model classusing System;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    TermInfo term = await client.Taxonomies("<TAXONOMY_UID>").Term("<TERM_UID>").Fetch<TermInfo>();
    Console.WriteLine($"{term.Uid}: {term.Name}");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
}Localized: read a term in a locale, with fallbackusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject term = await client.Taxonomies("<TAXONOMY_UID>")
        .Term("<TERM_UID>")
        .SetLocale("<LOCALE>")
        .IncludeFallback()
        .Fetch<JsonObject>();
    Console.WriteLine($"{term["name"]} ({term["locale"]})");
}
catch (ContentstackException e)
{
    Console.WriteLine(e.Message);
}
```

## IncludeBranch

IncludeBranch requests the branch information of the term by sending include\_branch=true.

```
Returns: Term. The same term, for chaining.
ValidationThere is no client-side validation.An invalid value surfaces as a ContentstackException (or a subclass) when Fetch, Ancestors or Descendants sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeBranch stores include_branch=true and makes no request. No method removes it, so build a new instance to send a request without it.Fetch, Ancestors and Descendants send the value. Locales does not.Does not choose the branch. The Branch option on ContentstackOptions sets the branch the SDK reads from.ExampleBasic usage: read a term with its branch informationusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject term = await client.Taxonomies("<TAXONOMY_UID>")
        .Term("<TERM_UID>")
        .IncludeBranch()
        .Fetch<JsonObject>();
    Console.WriteLine(term["_branch"]);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## IncludeFallback

IncludeFallback returns terms through the locale fallback hierarchy of the branch when they have no localization in the requested locale.

```
Returns: Term. The same term, for chaining.
ValidationThere is no client-side validation.An invalid value surfaces as a ContentstackException (or a subclass) when Fetch, Ancestors or Descendants sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. IncludeFallback stores include_fallback=true and makes no request. No method removes it, so build a new instance to send a request without it.Fetch, Ancestors and Descendants send the value. Locales does not.The API applies it per request:On Fetch, a term with no localization in the requested locale returns through the fallback hierarchy instead of a 404 error (Get a single term).On Ancestors, the term and its ancestors return through the fallback hierarchy (Get ancestors of a term).On Descendants, the response also includes the descendants that have no localization in the requested locale (Get descendants of a term).Works with or without SetLocale.To use the fallback hierarchy of a branch other than main, set Branch on ContentstackOptions, so the SDK sends the branch header.ExampleBasic usage: read a term with locale fallbackusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject term = await client.Taxonomies("<TAXONOMY_UID>")
        .Term("<TERM_UID>")
        .SetLocale("<LOCALE>")
        .IncludeFallback()
        .Fetch<JsonObject>();
    Console.WriteLine($"{term["name"]} ({term["locale"]})");
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

## Locales

Locales lists every published localized version of the term.

```
Returns: Task<T>. The localized versions of the term.
ValidationThere is no client-side validation.Throws TaxonomyException if the request fails, for example for an unknown taxonomy UID.Throws TaxonomyException with ErrorCode 0 if the response does not deserialize into T. A T that holds a single object, for example a model class, fails this way, because the SDK reads an array.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorCalls GET /taxonomies/{taxonomy_uid}/terms/{term_uid}/locales (Get a single term in all locales) and makes one HTTP request per call.Deserializes the terms array of the response into T and returns it. Each item is one localized version of the term.Sends only the environment. The query parameters stored on the instance, for example from SetLocale or AddParam, do not reach this request.Returns every localized version, whatever locale you set.ExampleBasic usage: list the localized versions of a termusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    List<TermInfo> versions = await client.Taxonomies("<TAXONOMY_UID>")
        .Term("<TERM_UID>")
        .Locales<List<TermInfo>>();
    foreach (TermInfo version in versions)
    {
        Console.WriteLine($"{version.Locale}: {version.Name}");
    }
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}

public class TermInfo
{
    public string Uid { get; set; }
    public string Name { get; set; }
    public string Locale { get; set; }
}
```

## SetLocale

SetLocale sets the locale that the term requests return the term names in.

```
Returns: Term. The same term, for chaining.
ValidationThere is no client-side validation of the locale code.A null or empty locale changes nothing. SetLocale keeps any locale set earlier and does not throw.An invalid value surfaces as a ContentstackException (or a subclass) when Fetch, Ancestors or Descendants sends the request.Additional Resource: Refer to Content Delivery API Errors for the full error code list.
BehaviorClient-side only. SetLocale stores the locale query parameter and makes no request. A second call replaces the first value.Fetch, Ancestors and Descendants send the value. Locales does not.Without IncludeFallback, Fetch returns a 404 error for a term that has no localization in this locale (Get a single term).A locale set on the Taxonomy does not reach the term. Set it on the Term itself.ExampleBasic usage: read a term in a localeusing System;
using System.Text.Json.Nodes;
using Contentstack.Core;
using Contentstack.Core.Internals;
using Contentstack.Core.Models;

ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");

try
{
    JsonObject term = await client.Taxonomies("<TAXONOMY_UID>")
        .Term("<TERM_UID>")
        .SetLocale("<LOCALE>")
        .Fetch<JsonObject>();
    Console.WriteLine(term["name"]);
}
catch (ContentstackException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.Message}");
}
```

Locale code, for example fr-fr.

## Term | .NET Delivery SDK | Contentstack

The Term class in the .NET Delivery SDK reads one published taxonomy term, lists its localized versions, and retrieves its ancestors and descendants.

## Endpoint

Endpoint is a static class in the Contentstack.Core.Endpoints namespace. It resolves the URL of a Contentstack service for a region, from the Contentstack regions registry. Use this class to

*   find the delivery host for a region before you create a client
*   find the URL of another Contentstack service, such as Image Delivery or Content Management, in the same region
*   list every service URL for a region

ContentstackClient calls Endpoint itself to resolve the delivery host when you set a region and no Host. You call it directly only when you need a URL for your own code.

## GetContentstackEndpoint

GetContentstackEndpoint resolves the URL of one Contentstack service for a region, or every service URL for that region.

```
Returns: string or Dictionary. The URL of one service, or every service URL for the region.
OverloadsGetContentstackEndpoint(string region, string service, bool omitHttps = false): Returns a string with the URL of one service.GetContentstackEndpoint(string region, bool omitHttps = false): Returns a Dictionary<string, string> that maps each service key to its URL.ValidationThrows ArgumentException if region is null, empty, or only spaces, because the SDK has no region to look up.Throws KeyNotFoundException if region matches no registry ID or alias, or if service names a key the region does not have.Throws InvalidOperationException if the SDK can neither read nor download regions.json, or the file is not valid registry JSON.Throws ArgumentNullException if service is null, because the registry lookup needs a key name.BehaviorGetContentstackEndpoint reads the in-memory registry. Only the first call in a process reads regions.json from disk or downloads it. See the Endpoint class page.Region matching ignores case and surrounding spaces. "US", "na", and " aws-na " all resolve to the na region.Service keys match case exactly. "ContentDelivery" throws KeyNotFoundException.omitHttps: true returns the bare host, such as eu-cdn.contentstack.com. Pass that form to the host argument of a ContentstackClient constructor, which adds the scheme itself.The dictionary overload returns a new dictionary on each call, so changes to it do not reach the registry.ExampleBasic usage: resolve the delivery URL for a regionusing System;
using System.Collections.Generic;
using Contentstack.Core.Endpoints;

try
{
    string url = Endpoint.GetContentstackEndpoint("eu", "contentDelivery");
    Console.WriteLine(url);
}
catch (KeyNotFoundException e)
{
    // Thrown when the region or the service key is not in the registry
    Console.WriteLine(e.Message);
}All parameters: a bare host for the client constructorusing System;
using System.Collections.Generic;
using Contentstack.Core;
using Contentstack.Core.Endpoints;

try
{
    string host = Endpoint.GetContentstackEndpoint("azure-na", "contentDelivery", omitHttps: true);
    ContentstackClient client = new ContentstackClient("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>", host: host);
    Console.WriteLine($"Client host: {host}");
}
catch (KeyNotFoundException e)
{
    Console.WriteLine(e.Message);
}Dictionary overload: list every service for a regionusing System;
using System.Collections.Generic;
using Contentstack.Core.Endpoints;

try
{
    Dictionary<string, string> endpoints = Endpoint.GetContentstackEndpoint("gcp-eu", omitHttps: true);
    foreach (KeyValuePair<string, string> endpoint in endpoints)
    {
        Console.WriteLine($"{endpoint.Key}: {endpoint.Value}");
    }
}
catch (KeyNotFoundException e)
{
    Console.WriteLine(e.Message);
}
```

Region ID or alias, such as eu.

Service key, such as contentDelivery.

Returns the host without the https:// scheme.

## ResetCache

ResetCache clears the in-memory copy of the region registry, so that the next lookup reads regions.json again.

```
Returns: void. This method returns nothing.
ValidationThere is no client-side validation, because ResetCache takes no argument. It never throws.BehaviorClient-side only. ResetCache clears the cached registry and makes no request.The next call to the GetContentstackEndpoint method reads regions.json from disk, or downloads it when the file is missing.ResetCache does not delete the regions.json file on disk. To pick up a newer registry in a running process, replace the file first, then call ResetCache.Every ContentstackClient that resolves its host from a region reads the same cache on each request. After ResetCache, the next request from such a client reloads the registry.ExampleBasic usage: reload the registry after you replace regions.jsonusing System;
using Contentstack.Core.Endpoints;

// Call after you replace Assets/regions.json next to Contentstack.Core.dll.
Endpoint.ResetCache();

string url = Endpoint.GetContentstackEndpoint("na", "contentDelivery");
Console.WriteLine(url);
```

## Endpoint | .NET Delivery SDK | Contentstack

The static Endpoint class in the .NET Delivery SDK resolves the URL of any Contentstack service, such as Content Delivery or Image Delivery, for a given region.