Skip to main content

Create a File

POST 

https://https://euwest.api.elasticpath.com/v2/files

Create a File

Request

Bodyrequired

    filestring<binary>

    Indicates the file you want to upload.

    Example: UploadFile
    file_locationstring

    Use this parameter to reference a file stored at a specific location. This must be the URL that points to an image file.

    Example: @/path/to/file.jpg

Responses

Created

Schema
    data File
    idstring<uuid>

    The unique identifier for this file.

    Example: 00000000-0000-0000-0000-000000000000
    typestring

    The type represents the object being returned.

    Example: file
    file_namestring

    The name of the file.

    Example: file_name.jpg
    mime_typestring

    The mime type of the file.

    Example: image/jpeg
    file_sizeinteger

    The size of the file. Required when uploading files.

    Example: 36000
    publicboolean

    DEPRECATED Whether the file public or not. Required when uploading files.

    Example: true
    meta FileMeta
    timestamps object

    The date and time the file was created.

    created_atstring

    The date and time the file was created.

    Example: 2023-10-11T13:02:25.293Z
    dimensions object

    The file dimensions.

    widthinteger

    The width of the file.

    Example: 1800
    heightinteger

    The height of the file.

    Example: 1000
    links object

    Links are used to allow you to move between requests.

    selfstring

    Single entities use a self parameter with a link to that specific resource.

    Example: https://https://euwest.api.elasticpath.com//v2/files/ddc28c74-a7df-46be-b262-8fa69a6e7d52
    link object

    The publicly available URL for this file.

    hrefstring

    The publicly available URL for this file.

    Example: https://files-eu.epusercontent.com/e8c53cb0-120d-4ea5-8941-ce74dec06038/f8cf26b3-6d38-4275-937a-624a83994702.png

Authorization: http

name: bearerAuthtype: httpscheme: bearer
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://https://euwest.api.elasticpath.com/v2/files");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <token>");
var content = new StringContent(string.Empty);
content.Headers.ContentType = new MediaTypeHeaderValue("multipart/form-data");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Request Collapse all
Base URL
https://https://euwest.api.elasticpath.com
Auth
Body required
Indicates the file you want to upload.
ResponseClear

Click the Send API Request button above and see the response here!