Import (with approval)

To import threat data (observables) into ThreatStream and require approval of the imported data through the ThreatStream UI. Unstructured data can be specified in any format, such as JSON, CSV, PDF, or plain text, and can be contained in a file or directly specified in the API call. You can also import data from plain text intelligence streams by specifying a URL. Once data has been imported, you must login to the ThreatStream UI and approve the import.

This method can be used to import unstructured and structured data. See Supported Data Formats for more information.

When importing unstructured data, all intelligence is associated with the same attributes—threat type, classification, confidence. For example, if a file has two IP addresses, each IP will be assigned the same indicator type based on the threat type you specify. See Request Attributes for a list of global settings that can be specified for imported observables.

However, when importing structured data, you can specify a different itype and tags for each observable in the structured file, which is different from the global settings. When a local setting is specified, it overrides the global setting.

Request

/api/v2/intelligence/import/

Important: /api/v1/intelligence/ requests are now deprecated. Anomali recommends using /api/v2/intelligence/ for all requests.

HTTP Method: POST

Attributes: See the table below

Request Attributes

These attributes specify global settings for imported observables. If an imported observable does not have an explicitly specified value for these settings, the global setting is applied. However, if an imported observable does have an explicitly specified value, it overrides the global value.

Attribute Type Description
actors string IDs of the actors with which you want to associate the imported intelligence.
campaigns string IDs of the campaigns with which you want to associate the imported intelligence.
classification string Classification of the observable—public or private.
confidence numeric

Confidence score that you (the source) want to assign to the imported observable(s) based on the level of confidence you have about the maliciousness of the observable.

Confidence scores range from 0-100, in increasing order of confidence.

If you want ThreatStream to use the confidence value that you specify and not re-assess the value using its machine-learning algorithms, see source_confidence_weight.

Note: ThreatStream only scores domain, IP, and URL observables. For all other observable types, you must specify a confidence value—either globally or per observable.
datatext string Text containing the observables you want to import.
default_state string

Whether the import job must be approved from the ThreatStream user interface before observables become active.

When default_state is set to active, observables become active upon submission, without requiring approval. In these cases, an import job is created on ThreatStream which is automatically approved.

You must have the Approve Import privilege in order to import observables through the API with default_state set to active.

If no value is specified for default_state, resulting import jobs are in Ready to Review status and must be approved from the ThreatStream user interface before observables become active.

expiration_ts date

Time stamp of when intelligence will expire on ThreatStream, in UTC format. For example, 2017-01-26T00:00:00.

By default, the expiration_ts is set to 90 days from the current date.

file string Path to the file from which the observables will be imported.
incidents string IDs of the incidents with which you want to associate the imported intelligence.
intelligence_source string Source from which the intelligence originated.
is_anonymous boolean

Whether you want to anonymize your organization information. Users outside of your organization with access to the observables will see "Analyst" in all fields that would otherwise display an organization or user name.

True—if you want to anonymize organization information

False—if you do not want to anonymize your organization information

malware string IDs of the malware with which you want to associate the imported intelligence.
reject_benign boolean

Whether benign observables—those assigned a confidence score of 15 or less—are automatically excluded from the import job.

True—if you want to reject benign observables

False—if you do not want to reject benign observables

By default, reject_benign is set to True.

remote_api (for ThreatStream OnPrem only) boolean

Whether intelligence is remote (stored on Cloud).

This attribute does not need to be set to ingest local intelligence. Only use this attribute when ingesting remote intelligence from ThreatStream Cloud. Set this attribute to true in this case.

Do not set this attribute to false for ingesting local intelligence. Doing so will generate errors.

severity string

Gauges the potential impact of the indicator type the observable is thought to be associated with.

Possible values: low, medium, high, very-high

Note: A default severity value is assigned to each imported observable, based on its indicator type. (See Help for the Severity field in the ThreatStream UI for a list of default severity values for indicator types.) However, if you want to override the default value, you can use this field.

source_confidence_weight numeric

Specifies the ratio between the amount of the source confidence of each observable and the ThreatStream's confidence. For example, if this setting = 30%, when calculating the final confidence, 30% weight is given to the confidence specified by the source of the observable and 70% weight is given to the confidence deemed by ThreatStream (based on the machine-learning algorithms).

Notes:

  • To use your source's confidence entirely, set source_confidence_weight to 100.
  • source_confidence_weight can only be specified as a request attribute. It cannot be specified in the structured CSV file.
  • In ThreatStream API, you can set the source confidence weight granularly, from 0 to 100 using the source_confidence_weight attribute.

  • This setting only applies to observables for which classification is set to private, including those shared with trusted circles.

  • This is the same setting as the Override System Confidence setting in ThreatStream UI (in Imports and Feeds). When this setting is unchecked, source_confidence_weight is set to 0, it means do not use source-reported confidence value. When this setting is checked, source_confidence_weight is set to 100, it means only use the source-reported confidence value—do not reassess the score using the machine-learning algorithms.

    Note: You cannot set this attribute granularly through the UI. You can only set this attribute to 0 or 100 through the UI.
source_locations list of string

Source locations assigned to the imported observables.

Possible values include letter codes of regions, countries, and administrative areas (US States and Washington DC only) as defined by STIX 2.1. For example, eastern-africa, central-asia, europe, africa, NL, GB, US-FL, and US-MO.

tags string

Tags applied to the imported observables.

Tags must be specified as follows:

tags: [{"name": "my_tag","tlp": "red"},{"name": "my_tag2","tlp": "clear"},{"name": "my_tag3"}]

Tag Attributes:

  • name—name of the tag that you want to add.

  • tlp—the visibility setting for the tag. Possible values: red, amber, amber+strict, green, clear.

  • red—private, or visible to your organization only.

  • white—public, or visible to all ThreatStream users with access to the data. Default: white.

    Note: Adding public tags may be restricted by your Organization Administrator.

    In the example above, my_tag is private and my_tag2 and my_tag3 are public.

target_industry list of strings Target industries assigned to the imported observables. Possible values are defined by the STIX 2.1 Industry Sector vocabulary.

For example, chemical, financial-services, and government-regional.

target_locations list of strings

Target locations assigned to the imported observables.

Possible values include letter codes of regions, countries, and administrative areas (US States and Washington DC only) as defined by STIX 2.1. For example, eastern-africa, central-asia, europe, africa, NL, GB, US-FL, and US-MO.

threat_type string

Type of threat associated with the imported observables. ThreatStream assigns observable types based on the threat type you specify. For a complete list of threat types, see Threat Types in ThreatStream.

If you specify a threat type not associated with observable types that map to the observables you import, imported observables will be assigned malware indicator types by default. For example, if you import a file hash and specify the adware threat type—whose only indicator type association is "adware_domain"—ThreatStream will assign the malware_md5 indicator type by default.

tipreports string IDs of the tipreports with which you want to associate the imported intelligence.
tlp string

Traffic Light Protocol designation for the intelligence—red, amber, amber+strict, green, clear.

trustedcircles numeric

ID of the trusted circle to which this threat data should be imported. If you want to import the threat data to multiple trusted circles, enter the list of comma-separated IDs.

To find the ID of a trusted circle, locate the trusted circle on ThreatStream, click on its name. The URL displayed in the address bar shows the ID. For example, https://ui.threatstream.com/search?trusted_circle_ids=13.

ttps string IDs of the ttps with which you want to associate the imported intelligence.
Type-specific mappings
Note: If you do not specify a threat_type in your request, you must specify indicator type mappings for each of the following attributes. See Indicator Types in ThreatStream for a complete list of supported values. See Fraud Indicator Types for ThreatStream OnPrem for a list of indicator types exclusive to ThreatStream OnPrem.
domain_mapping string

Indicator type to assign if a specific type is not associated with an observable.

This is a global setting that applies to any imported domain-type observable when an explicit itype is not specified for it.

email_mapping string

Indicator type to assign if a specific type is not associated with an observable.

This is a global setting that applies to any imported email-type observable when an explicit itype is not specified for it.

ip_mapping string

Indicator type to assign if a specific type is not associated with an observable.

This is a global setting that applies to any imported IP-type observable when an explicit itype is not specified for it.

md5_mapping string

Indicator type to assign if a specific type is not associated with an observable.

This is a global setting that applies to any imported MD5-type observable when an explicit itype is not specified for it.

url_mapping string

Indicator type to assign if a specific type is not associated with an observable.

This is a global setting that applies to any imported URL-type observable when an explicit itype is not specified for it.

Supported Data Formats

This API call can be used to import unstructured and structured data.

Unstructured Data

There are no specific requirements for unstructured data.

Structured Data

Follow these guidelines when importing structured data:

  • The structured data must be contained in a valid CSV file with the following header line: value, itype, tags. Optional columns include private_tags, is_anonymous, and tlp.

    value itype tags private_tags is_anonymous tlp
    1.2.3.4 brute_ip exploitation, phishing   true green
    https://example.com apt_url phishing sensitive   amber
    4d68462ca6071f9b6ad0fabea8bd1c9f mal_md5     false red
    %.skydome.com mal_wildcard_domain malware_domains      
    https://bluebird.com/% suspicious_wildcard_url sus_urls      
Note: Observables with the percent symbol (%) represent wildcard domains and URLs. To learn more about wildcard observables, refer to Wildcard Observables.
  • The value header label is mandatory. This column must contain data.

  • For domain, email, IP, MD5, and URL observables, itype, tags, and private_tags header labels can be omitted if no data will be specified for these columns. For all other observables, you must specify a value for itype. See Indicator Types in ThreatStream.
  • tags is a comma-separated list of tags. Tags included in the tags column are assigned the Anomali Community visibility setting and visible to all users with access to the observable.
  • private_tags is a comma-separated list of tags. Tags included in the private_tags column are assigned the My Organization visibility setting and visible only to users in your organization.
  • is_anonymous sets whether the organization and user information for the observable is anonymized. Possible values include true and false. If no value is specified, observables will not be anonymized.
  • tlp sets a TLP color for the observable. Possible values include clear, green, amber, amber+strict, and red.
  • The data specified in itype and tags columns overrides the global settings specified in the Request Attributes settings. For example, if the structured CSV contains the following: value=1.2.3.4, itype=phish_ip, and Request Attribute ip_mapping=mal_ip, then itype for the observable 1.2.3.4 will be set to phish_ip because the setting in the file (local value) will override the Request Attribute setting (global value).
  • If the itype and tags columns are empty, the data for these columns is derived from the Request Attributes settings. For example, if value=1.2.3.4, itype is not specified in the file, tags is not specified in the file, and the Request Attribute ip_mapping=mal_ip, then itype for the observable will be set to mal_ip.

Examples

  1. To import observables from a file. The file can contain unstructured or structured data.

    curl example:

    Copy
    curl -X POST 'https://api.threatstream.com/api/v2/intelligence/import/'  -F "confidence=30" -F "classification=private"  -F "threat_type=malware" -F "file=@<filename>" -H 'Authorization: apikey <username>:<api_key>'

    Python example:

    def import_with_approval_using_file(username, api_key):
        auth = 'apikey {}:{}'.format(username, api_key)
        headers = {'Authorization': auth}
        api_url = "https://api.threatstream.com/api/v2/intelligence/import/"
        tags = [{'name': 'private_tag', 'tlp': 'red'}]
        payload={
            'classification': 'private',
            'confidence': 70,
            'threat_type': 'malware',
            'tags': json.dumps(tags)
        }
        filename = '<name_of_your_file>' #this can be a .txt, .csv or .pdf file
        files = {'file': open(filename, 'rb')}
    response = requests.post(api_url, headers=headers, data=payload, files=files)
    print(response.text)
  2. To import observables directly, by specifying them in the API call:

    curl example:

    Copy
    curl -X POST 'https://api.threatstream.com/api/v2/intelligence/import/'  -F "confidence=70" -F "classification=private" -F "threat_type=apt" -F "datatext=<text_to_parse_and_import>" -H 'Authorization: apikey <username>:<api_key>'

    Python example:

    def import_with_approval_using_datatext(username, api_key):
        auth = 'apikey {}:{}'.format(username, api_key)
        headers = {'Authorization': auth}
        url = "https://api.threatstream.com/api/v2/intelligence/import/"
        tags = [{'name': 'public_tag'}, {'name': 'private_tag', 'tlp': 'red'}]
        payload={
            'classification': 'private',
            'confidence': 65,
            'threat_type': 'malware',
            'tags': json.dumps(tags),
            'datatext': <text_to_parse_and_import>'
        }
    response = requests.post(url, headers=headers, data=payload)
    print(response.text)
    
  3. To import observables from a plain text intelligence stream by specifying a URL:

    curl example:

    Copy
    curl -X POST 'https://api.threatstream.com/api/v2/intelligence/import/'  -F "confidence=60" -F "classification=private"  -F "threat_type=c2" -F "url=<url_for_plain_text_stream>" -H 'Authorization: apikey <username>:<api_key>'

    Python example:

    def import_with_approval_using_url(username, api_key):
        auth = 'apikey {}:{}'.format(username, api_key)
        headers = {'Authorization': auth}
        api_url = "https://api.threatstream.com/api/v2/intelligence/import/"
        tags = [{'name': 'public_tag'}, {'name': 'private_tag', 'tlp': 'red'}]
        url = "<your_url>"
        payload={
            'classification': 'private',
            'confidence': 70,
            'threat_type': 'malware',
            'tags': json.dumps(tags),
            'url': url
         }
    response = requests.post(api_url, headers=headers, data=payload)
    print(response.text)
  4. To import observables associated with tags that are private to your organization:

    Copy
    curl -X POST 'https://api.threatstream.com/api/v2/intelligence/import/' -F "threat_type=malware" -F "datatext=<text_to_parse_and_import>" -F "classification=private" -F "confidence=40" -F 'tags=[{"name":"my_tag", "tlp":"red"},{"name":"another_private_tag", "tlp":"red"}]' -H 'Authorization: apikey <username>:<api_key>'
  5. To import observables and share them with trusted circles whose ids are 1 and 2:

    Copy
    curl -X POST 'https://api.threatstream.com/api/v2/intelligence/import/' -F "confidence=80" -F "classification=private" -F "trustedcircles=1,2" -F "threat_type=phish" -F "datatext=<text_to_parse_and_import>" -H 'Authorization: apikey <username>:<api_key>'
  6. To automatically approve imported observables. An import job is created and observables are set to active:

    Copy
    curl -X POST 'https://api.threatstream.com/api/v2/intelligence/import/' -F "classification=private" -F "threat_type=malware" -F 'tags=[{"name":"tag1","tlp":"red"}]' -F "datatext=<text_to_parse_and_import>" -F "default_state=active" -H 'Authorization: apikey <username>:<api_key>'
    Copy
    curl -X POST 'https://api.threatstream.com/api/v2/intelligence/import/' -F "file=<filename>" -F "confidence=30" -F "classification=private" -F "threat_type=malware" -F "data_type=unstructured" -H "Authorization: apikey <username>:<api_key>"
  7. To import observables and create an association between the import job and an Actor whose ID is 77:

    Copy
    curl -X POST 'https://api.threatstream.com/api/v2/intelligence/import/' -F "actors=77" -F "threat_type=apt" -F "datatext=<text_to_parse_and_import>" -H 'Authorization: apikey <username>:<api_key>'
  8. To import wildcard observables in a CSV file. The file includes structured data.

    Copy
    curl -X POST 'https://api.threatstream.com/api/v2/intelligence/import/' -F "confidence=30" -F "classification=private" -F "threat_type=malware" -F "file=@<filename>" -H 'Authorization: apikey <username>:<api_key>'

     

Response

HTTP 202 Accepted {"import_session_id": IMPORT_SESSION_ID, "success": STATUS, "job_id": BACKGROUND_JOB_ID}

where

import_session_id is the ID for the import job. You will need this ID to check the status of the import job.

job_id is an identifier for the job on ThreatStream.

Example Response:

{"job_id": "6194c7c0-53ae-41fc-a6f0-dc3d174f02e2", "success": true, "import_session_id": "482"}

Checking status of an Import job

Use this API call to periodically poll the status of an import job:

Copy
curl -X GET 'https://api.threatstream.com/api/v1/importsession/import_session_id/' -H 'Authorization: apikey <username>:<api_key>'

where import_session_id is the identifier that was returned in the response of the Import call.

This call returns one of the following statuses in the "status" attribute:

  • processing—the import process is in progress. Keep polling periodically.
  • errors—the import process failed.
  • done—the import process has completed.

    At this point, the call also returns numIndicators and numRejected attributes that denote the number of observables that were accepted for importing and the observables that were rejected, respectively. This information is the same as the one displayed on the Import Review page of the ThreatStream UI.

Getting Observable ID in an Import Job

Note: Before executing this call, make sure that the import job belongs to your organization.

Use this API to get IDs of the observables in an import job.

Copy
curl -X GET 'https://api.threatstream.com/api/v1/importsession/<import_session_id>/intelligence' -H 'Authorization: apikey <username>:<api_key>'

where <import_session_id> is the identifier of the import job.

This call returns the information about the import job. You can view IDs of the observables in the "id" attribute.

Approving All Observables in an Import Job

Note:

  • Before executing this call, make sure that the import job belongs to your organization.

  • You must have the Approve Intelligence user permission to use this API call. Organization Administrators can grant you this permission by adding it to your user role on the User & Role Management page. See Managing Roles for details.

Use this API call to approve all observables in an import job:

Copy
curl -X PATCH 'https://api.threatstream.com/api/v1/importsession/<import_session_id>/approve_all' -H 'Authorization: apikey <username>:<api_key>'

where <import_session_id> is the identifier of the import job.

Approving Selected Observables in an Import Job

Note:  

  • Before executing this call, make sure that the import job belongs to your organization.

  • You must have the Approve Intelligence user permission to use this API call. Organization Administrators can grant you this permission by adding it to your user role on the User & Role Management page. See Managing Roles for details.

Use this API call to approve selected observables in an import job:

Copy
curl -X PATCH 'https://api.threatstream.com/api/v1/importsession/<import_session_id>/approve_selected/?ids=<id1>,<id2>' -H 'Authorization: apikey <username>:<api_key>'

where

<import_session_id> is the identifier of the import job.

ids=<id1>,<id2> is a comma-separated list of IDs of the observables to be imported.