# Create a function

Launch stage: GA

`POST /api/2.1/unity-catalog/functions`

**WARNING: This API is experimental and will change in future versions**

 Creates a new function

 The user must have the following permissions in order for the function to be created:
 - **USE_CATALOG** on the function's parent catalog
 - **USE_SCHEMA** and **CREATE_FUNCTION** on the function's parent schema

API scopes: unity-catalog

## Request body

- `function_info` (object, required)
  Partial __FunctionInfo__ specifying the function to be created.
  - `name` (string, optional)
    Name of function, relative to parent schema.
  - `catalog_name` (string, optional)
    Name of parent Catalog.
  - `schema_name` (string, optional)
    Name of parent Schema relative to its parent Catalog.
  - `input_params` (object, optional)
    Function input parameters.
    - `parameters` (array of object, optional)
      - `name` (string, required)
        Name of Parameter.
      - `type_text` (string, required)
        Full data type spec, SQL/catalogString text.
      - `type_json` (string, optional)
        Full data type spec, JSON-serialized.
      - `type_name` (string, required)
        Name of type (INT, STRUCT, MAP, etc.)
        Possible values:
        - `BOOLEAN`
        - `BYTE`
        - `SHORT`
        - `INT`
        - `LONG`
        - `FLOAT`
        - `DOUBLE`
        - `DATE`
        - `TIMESTAMP`
        - `STRING`
        - `BINARY`
        - `DECIMAL`
        - `INTERVAL`
        - `ARRAY`
        - `STRUCT`
        - `MAP`
        - `CHAR`
        - `NULL`
        - `USER_DEFINED_TYPE`
        - `TIMESTAMP_NTZ`
        - `VARIANT`
        - `GEOMETRY`
        - `GEOGRAPHY`
        - `TABLE_TYPE`
      - `type_precision` (int32, optional)
        Digits of precision; required on Create for DecimalTypes.
      - `type_scale` (int32, optional)
        Digits to right of decimal; Required on Create for DecimalTypes.
      - `type_interval_type` (string, optional)
        Format of IntervalType.
      - `position` (int32, required)
        Ordinal position of column (starting at position 0).
      - `parameter_mode` (string, optional)
        Function parameter mode.
        Possible values:
        - `IN`
      - `parameter_type` (string, optional)
        Function parameter type.
        Possible values:
        - `PARAM`
        - `COLUMN`
      - `parameter_default` (string, optional)
        Default value of the parameter.
      - `comment` (string, optional)
        User-provided free-form text description.
  - `data_type` (string, optional)
    Scalar function return data type.
    Possible values:
    - `BOOLEAN`
    - `BYTE`
    - `SHORT`
    - `INT`
    - `LONG`
    - `FLOAT`
    - `DOUBLE`
    - `DATE`
    - `TIMESTAMP`
    - `STRING`
    - `BINARY`
    - `DECIMAL`
    - `INTERVAL`
    - `ARRAY`
    - `STRUCT`
    - `MAP`
    - `CHAR`
    - `NULL`
    - `USER_DEFINED_TYPE`
    - `TIMESTAMP_NTZ`
    - `VARIANT`
    - `GEOMETRY`
    - `GEOGRAPHY`
    - `TABLE_TYPE`
  - `full_data_type` (string, optional)
    Pretty printed function data type.
  - `routine_body` (string, optional)
    Function language. When **EXTERNAL** is used, the language of the routine function should be specified in the **external_language** field, and the **return_params** of the function cannot be used (as **TABLE** return type is not supported), and the **sql_data_access** field must be **NO_SQL**.
    Possible values:
    - `SQL`
    - `EXTERNAL`
  - `routine_definition` (string, optional)
    Function body.
  - `parameter_style` (string, optional)
    Function parameter style. **S** is the value for SQL.
    Possible values:
    - `S`
  - `is_deterministic` (boolean, optional)
    Whether the function is deterministic.
  - `sql_data_access` (string, optional)
    Function SQL data access.
    Possible values:
    - `CONTAINS_SQL`
    - `READS_SQL_DATA`
    - `NO_SQL`
  - `is_null_call` (boolean, optional)
    Function null call.
  - `security_type` (string, optional)
    Function security type.
    Possible values:
    - `DEFINER`
  - `specific_name` (string, optional)
    Specific name of the function; Reserved for future use.
  - `return_params` (object, optional)
    Table function return parameters.
    - `parameters` (array of object, optional)
      - `name` (string, required)
        Name of Parameter.
      - `type_text` (string, required)
        Full data type spec, SQL/catalogString text.
      - `type_json` (string, optional)
        Full data type spec, JSON-serialized.
      - `type_name` (string, required)
        Name of type (INT, STRUCT, MAP, etc.)
        Possible values:
        - `BOOLEAN`
        - `BYTE`
        - `SHORT`
        - `INT`
        - `LONG`
        - `FLOAT`
        - `DOUBLE`
        - `DATE`
        - `TIMESTAMP`
        - `STRING`
        - `BINARY`
        - `DECIMAL`
        - `INTERVAL`
        - `ARRAY`
        - `STRUCT`
        - `MAP`
        - `CHAR`
        - `NULL`
        - `USER_DEFINED_TYPE`
        - `TIMESTAMP_NTZ`
        - `VARIANT`
        - `GEOMETRY`
        - `GEOGRAPHY`
        - `TABLE_TYPE`
      - `type_precision` (int32, optional)
        Digits of precision; required on Create for DecimalTypes.
      - `type_scale` (int32, optional)
        Digits to right of decimal; Required on Create for DecimalTypes.
      - `type_interval_type` (string, optional)
        Format of IntervalType.
      - `position` (int32, required)
        Ordinal position of column (starting at position 0).
      - `parameter_mode` (string, optional)
        Function parameter mode.
        Possible values:
        - `IN`
      - `parameter_type` (string, optional)
        Function parameter type.
        Possible values:
        - `PARAM`
        - `COLUMN`
      - `parameter_default` (string, optional)
        Default value of the parameter.
      - `comment` (string, optional)
        User-provided free-form text description.
  - `external_name` (string, optional)
    External function name.
  - `external_language` (string, optional)
    External function language.
  - `sql_path` (string, optional)
    List of schemes whose objects can be referenced without qualification.
  - `owner` (string, optional)
    Username of current owner of the function.
  - `comment` (string, optional)
    User-provided free-form text description.
  - `properties` (string, optional)
    JSON-serialized key-value pair map, encoded (escaped) as a string.
  - `routine_dependencies` (object, optional)
    Function dependencies. For external UDFs, dependencies may
     contain only credential, secret, or volume objects.
    - `dependencies` (array of object, optional)
      Array of dependencies.
      - `table` (object, optional)
        - `table_full_name` (string, required)
          Full name of the dependent table, in the form of __catalog_name__.__schema_name__.__table_name__.
      - `function` (object, optional)
        - `function_full_name` (string, required)
          Full name of the dependent function, in the form of __catalog_name__.__schema_name__.__function_name__.
      - `connection` (object, optional)
        - `connection_name` (string, optional)
          Full name of the dependent connection, in the form of __connection_name__.
      - `credential` (object, optional)
        - `credential_name` (string, optional)
          Full name of the dependent credential, in the form of __credential_name__.
  - `metastore_id` (string, optional)
    Unique identifier of parent metastore.
  - `full_name` (string, optional)
    Full name of Function, in form of **catalog_name**.**schema_name**.**function_name**
  - `created_at` (int64, optional)
    Time at which this function was created, in epoch milliseconds.
  - `created_by` (string, optional)
    Username of function creator.
  - `updated_at` (int64, optional)
    Time at which this function was last modified, in epoch milliseconds.
  - `updated_by` (string, optional)
    Username of user who last modified the function.
  - `function_id` (string, optional)
    Id of Function, relative to parent schema.
  - `browse_only` (boolean, optional)
    Indicates whether the principal is limited to retrieving metadata for the associated object through the BROWSE privilege when include_browse is enabled in the request.

## Returns

Returns the FunctionInfo object.

## Response

```json
{
  "name": "string",
  "catalog_name": "string",
  "schema_name": "string",
  "input_params": {
    "parameters": [
      {}
    ]
  },
  "data_type": "BOOLEAN",
  "full_data_type": "string",
  "routine_body": "SQL",
  "routine_definition": "string",
  "parameter_style": "S",
  "is_deterministic": true,
  "sql_data_access": "CONTAINS_SQL",
  "is_null_call": true,
  "security_type": "DEFINER",
  "specific_name": "string",
  "return_params": {
    "parameters": [
      {}
    ]
  },
  "external_name": "string",
  "external_language": "string",
  "sql_path": "string",
  "owner": "string",
  "comment": "string",
  "properties": "string",
  "routine_dependencies": {
    "dependencies": [
      {}
    ]
  },
  "metastore_id": "string",
  "full_name": "string",
  "created_at": 0,
  "created_by": "string",
  "updated_at": 0,
  "updated_by": "string",
  "function_id": "string",
  "browse_only": true
}
```

