# CreateAssetInLibrary

## Parameters

The following URL, Headers and Parameters are required for requests to this API endpoint. Where a parameter is optional, it will be indicated. Otherwise treat all parameters as mandatory.

### Headers

```
POST /api/ss/library/asset HTTP/1.1
Host: demo.attackforge.com
X-SSAPI-KEY: APIKey
Content-Type: application/json
Connection: close
```

### Query

**name (string)**

Name of the asset.

Example:

```
{
   "name": "..."
}
```

**type (string)**

Type of asset. Must be one of the following: *Web App, API, Mobile, Cloud, Infrastructure, Network, Wifi, Hardware, Other* or another custom type enabled in Global Configuration.

Example:

```
{
   "type": "Web App"
}
```

**external\_id (string) (optional)**

External id for the asset. For example id associated with the asset in Configuration Management Database.

Example:

```
{
   "external_id": "..."
}
```

**asset\_library\_ids (*****array of strings*****) (*****optional*****)**

Asset libraries to map asset against.

Example:

```
{
   "asset_library_ids": ["6569608e55bc00bacc67b417", "...", "..."]
}
```

**details (string) (optional)**

Details or notes relating to the asset.

Example:

```
{
   "details": "..."
}
```

**groups (array of strings) (optional)**

List of AttackForge Groups to associate the asset with. Must include the Group Id.

Example:

```
{
   "groups": ["5f31f2f1ccb8be08c49803d5", "5f9f5a5505c52f09833fa4e3"]
}
```

**custom\_fields (*****array of objects*****) (*****optional*****)**

Custom fields. Must include a key and value. Key must be unique and letters, numbers and underscores only.

For more information visit <https://support.attackforge.com/attackforge-enterprise/getting-started/custom-fields-and-forms#using-custom-fields-with-apis>

Example:

```
{   "custom_fields": [{"key": "...", "value": "..."}]}
```

## Example

The following example is a cURL request to create an asset in the library.

### Request

Include API Token instead of stars in 'X-SSAPI-KEY: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' parameter.

```
curl -X POST 'https://demo.attackforge.com/api/ss/library/asset' -H 'Host: localhost:3000' -H 'X-SSAPI-KEY: ***************************************' -H 'Content-Type: application/json' -H 'Connection: close' -d '{
  "name": "attackforge.com",
  "type": "Web App",
  "external_id": "ASSET001",
  "details": "This is the web site for AttackForge corporation.",
  "groups": ["5f31f2f1ccb8be08c49803d5", "5f9f5a5505c52f09833fa4e3"],
  "custom_fields": [{"key": "asset_owner", "value": "Bruce Wayne"}]
}'
```

### Response

Response contains an asset library object.

```
{
   "asset": {
      "id": "...",
      "created": "...",
      "modified": "...",
      "name": "...",
      "type": "...",
      "external_id": "...",
      "details": "...",
      "groups": [
        {
          "name": "...", 
          "id": "..."
        }
      ],
      "asset_library_ids": [
        {
          "id": "...",
          "name": "..."
        }
      ],
      "custom_fields" : [
         {
            "key" : "...",
            "value" : "..."
         }
      ]
   }   
}
```


---

# Agent Instructions: Querying This Documentation

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

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

```
GET https://support.attackforge.com/attackforge-enterprise/modules/self-service-restful-api/createassetinlibrary.md?ask=<question>
```

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

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