The newFile() GraphQL mutation may be used to create a new file.

To update a file, use the updateFile() mutation. Use deleteFile() to delete one. You can use the query, getFileContent() to get information on a file.

Hide Query Example

Show Files Query

For information on loading and using files, see the Lookup Files documentation page.

API Stability Long-Term

Syntax

graphql
newFile(
     fileName: string!, 
     name: string!,
     labels: [string]
   ): UploadedFileSnapshot!

You'll have to provide the name of the file and the repository. You may also give a list of labels associated with the file.

For the results, you can get the file path, the number of lines the CSV file contains, any headers and other such information. See the Returned Datatype section for more.

Example

Raw
graphql
mutation {
  newFile( 
     fileName: "somefile.csv",
     name: "humio",
  ) 
  { nameAndPath {path} }
}
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 {
  newFile( 
     fileName: \"somefile.csv\",
     name: \"humio\",
  ) 
  { nameAndPath {path} }
}"
}
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 {
  newFile( 
     fileName: \"somefile.csv\",
     name: \"humio\",
  ) 
  { nameAndPath {path} }
}"
}
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 { ^
  newFile(  ^
     fileName: \"somefile.csv\", ^
     name: \"humio\", ^
  )  ^
  { nameAndPath {path} } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  newFile( 
     fileName: \"somefile.csv\",
     name: \"humio\",
  ) 
  { nameAndPath {path} }
}"
}'
    "$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 {
  newFile( 
     fileName: \"somefile.csv\",
     name: \"humio\",
  ) 
  { nameAndPath {path} }
}";
$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 {
  newFile( 
     fileName: \"somefile.csv\",
     name: \"humio\",
  ) 
  { nameAndPath {path} }
}"
}'''

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 {
  newFile( 
     fileName: \"somefile.csv\",
     name: \"humio\",
  ) 
  { nameAndPath {path} }
}"
}
);


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": {
    "newFile": {
      "nameAndPath": {
        "path": null
      }
    }
  }
}

Given Datatype

For the input, you'll have to give the name of the file and the repository. You may also give a list of labels associated with the file.

Table: Input Using Standard Datatypes

Parameter Type Required Default Description
fileName string yes   The name of the new file.
labels [string]     A list of labels associated with the file.
name string yes   The name of the respository.

Returned Datatype

This datatype can return the file path, the number of lines the CSV file contains, any headers and other such information. The table below describes what information would be available:

Table: UploadedFileSnapshot

ParameterTypeRequiredDefaultStabilityDescription
Some arguments may be required, as indicated in the Required column. For return datatypes, this indicates that you must specify which fields you want returned in the results.
Table last updated: Sep 11, 2025
filterStringstring  Long-TermAny string on which to filter the data.
headers[string]yes Long-TermThe headers for the uploaded snapshot file.
limitintegeryes Long-TermThe file upload limit.
lines[string]yes Long-TermThe contents of the file in the form of a list of lines, with each line being itself a list of column values. When the file is empty or nothing matches filterString, then [] is returned.
nameAndPathFileNameAndPathyes Long-TermThe name and path of the uploaded snapshot file. See FileNameAndPath.
offsetintegeryes Long-TermThis is the offset supplied to a file query. For a new or updated file, this is always 0.
resourcestringyes Short-TermThe resource identifier for the file.
totalLinesCountlongyes Long-TermThe total number of lines in the uploaded snapshot file.