Summary

The deleteSearchDomain() mutation permanently deletes a repository or view identified by its string name. Deleting a repository removes all ingested data, parsers, alerts, scheduled searches, and other associated resources — this action cannot be undone through normal means. Deleting a view removes only the view configuration; the underlying repository data is unaffected. To recover a deleted search domain, use restoreDeletedSearchDomain() before the retention period expires. To delete by unique identifier rather than by name, use deleteSearchDomainById().

Syntax

graphql
deleteSearchDomain(
      name: String!, deleteMessage: String
   ): BooleanResultType!

The name argument is required and must exactly match the name of the repository or view to delete, including case. The optional deleteMessage argument records a reason for the deletion in the audit log; omitting it leaves no audit trail entry for the operation.

The mutation returns a non-null BooleanResultType!. The result field within BooleanResultType is true when the deletion succeeds and false when it does not. See the Returned Values section for the full field list.

Example

Raw
graphql
mutation {
  deleteSearchDomain( 
        name: "my-repository",
        deleteMessage: "It's Over!"
  )
  {result}
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  deleteSearchDomain( 
        name: \"my-repository\",
        deleteMessage: \"It's Over!\"
  )
  {result}
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  deleteSearchDomain( 
        name: \"my-repository\",
        deleteMessage: \"It's Over!\"
  )
  {result}
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "mutation { ^
  deleteSearchDomain(  ^
        name: \"my-repository\", ^
        deleteMessage: \"It's Over!\" ^
  ) ^
  {result} ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  deleteSearchDomain( 
        name: \"my-repository\",
        deleteMessage: \"It's Over!\"
  )
  {result}
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $query = "mutation {
  deleteSearchDomain( 
        name: \"my-repository\",
        deleteMessage: \"It's Over!\"
  )
  {result}
}";
$query =~ s/\n/ /g;
my $json = sprintf('{"query" : "%s"}',$query);
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");

$req->content( $json );

my $lwp = LWP::UserAgent->new;

my $result = $lwp->request( $req );

print $result->{"_content"},"\n";
Python
python
#! /usr/local/bin/python3

import requests

url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "mutation {
  deleteSearchDomain( 
        name: \"my-repository\",
        deleteMessage: \"It's Over!\"
  )
  {result}
}"
}'''

resp = requests.post(url,
                     data = mydata,
                     headers = {
   "Authorization" : "Bearer $TOKEN",
   "Content-Type" : "application/json"
}
)

print(resp.text)
Node.js
javascript
const https = require('https');

const data = JSON.stringify(
    {"query" : "mutation {
  deleteSearchDomain( 
        name: \"my-repository\",
        deleteMessage: \"It's Over!\"
  )
  {result}
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL',
  path: 'graphql',
  port: 443,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Authorization: 'BEARER ' + process.env.TOKEN,
    'User-Agent': 'Node',
  },
};

const req = https.request(options, (res) => {
  let data = '';
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', (d) => {
    data += d;
  });
  res.on('end', () => {
    console.log(JSON.parse(data).data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "deleteSearchDomain": {
      "result": true
    }
  }
}

Input Parameters

Provide the exact name of the repository or view to delete. The name argument is case-sensitive and must match the stored name precisely. Optionally include a deleteMessage to record a reason in the audit log; this is recommended for operational accountability, particularly when removing repositories that contain production data.

Table: Input Parameters and Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this mutation.
deleteMessage string     A reason to record in the audit log for this deletion. Omitting this argument leaves no audit trail entry for the operation. Providing a message is recommended whenever you delete a repository, because the deletion is destructive and irreversible.
name string yes   The exact name of the repository or view to delete. This value is case-sensitive and must match the stored name precisely. Use the searchDomains() query to confirm the name before calling this mutation.

Returned Values

The mutation returns a non-null BooleanResultType! containing a result field that is true when the deletion succeeds. The following table describes all fields in this type.

Table: BooleanResultType Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
resultBooleanyes Long-Term Whether the mutation was performed successfully.