<commit_before>---
type: doc
layout: reference
category: "Syntax"
title: "Opt-in Requirements"
---

# Opt-in Requirements

> The opt-in requirement annotations `@RequiresOptIn` and `@OptIn` are *experimental* in Kotlin 1.3.
> See the usage details [below](#experimental-status-of-the-opt-in-requirements).
{:.note}

The Kotlin standard library provides a mechanism for requiring and giving explicit consent for using certain elements of APIs.
This mechanism lets library developers inform users of their APIs about specific conditions that require opt-in,
for example, if an API is in the experimental state and is likely to change in the future. 

To prevent potential issues, the compiler warns users of such APIs about these conditions and
requires them to opt in before using the API.

## Opting in to using API
<commit_msg>chore: add note about previous names of opt-in annotations (#1644)<commit_after>---
type: doc
layout: reference
category: "Syntax"
title: "Opt-in Requirements"
---

# Opt-in Requirements

> The opt-in requirement annotations `@RequiresOptIn` and `@OptIn` are *experimental*. 
> See the usage details [below](#experimental-status-of-the-opt-in-requirements).
{:.note} 

> `@RequireOptIn` and `@OptIn` annotations were introduced in 1.3.70 to replace previously used `@Experimental` and `@UseExperimental`;
> at the same time, `-Xopt-in` compiler option replaced `-Xuse-experimental`.
{:.note} 


The Kotlin standard library provides a mechanism for requiring and giving explicit consent for using certain elements of APIs.
This mechanism lets library developers inform users of their APIs about specific conditions that require opt-in,
for example, if an API is in the experimental state and is likely to change in the future. 

To prevent potential issues, the compiler warns users of such APIs about these conditions and
requires them to opt in before using the API.

## Opting in to using API

{'fraction_non_alphanumeric': 0.07852314092563703, 'fraction_numerical': 0.005200208008320333, 'mean_word_length': 4.67551622418879, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3423134', 'n_tokens_mistral': 538, 'n_tokens_neox': 493, 'n_words': 255}