GetFolder - Amazon CodeCommit
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).


Returns the contents of a specified folder in a repository.

Request Syntax

{ "commitSpecifier": "string", "folderPath": "string", "repositoryName": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.


A fully qualified reference used to identify a commit that contains the version of the folder's content to return. A fully qualified reference can be a commit ID, branch name, tag, or reference such as HEAD. If no specifier is provided, the folder content is returned as it exists in the HEAD commit.

Type: String

Required: No


The fully qualified path to the folder whose contents are returned, including the folder name. For example, /examples is a fully-qualified path to a folder named examples that was created off of the root directory (/) of a repository.

Type: String

Required: Yes


The name of the repository.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 100.

Pattern: [\w\.-]+

Required: Yes

Response Syntax

{ "commitId": "string", "files": [ { "absolutePath": "string", "blobId": "string", "fileMode": "string", "relativePath": "string" } ], "folderPath": "string", "subFolders": [ { "absolutePath": "string", "relativePath": "string", "treeId": "string" } ], "subModules": [ { "absolutePath": "string", "commitId": "string", "relativePath": "string" } ], "symbolicLinks": [ { "absolutePath": "string", "blobId": "string", "fileMode": "string", "relativePath": "string" } ], "treeId": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.


The full commit ID used as a reference for the returned version of the folder content.

Type: String


The list of files in the specified folder, if any.

Type: Array of File objects


The fully qualified path of the folder whose contents are returned.

Type: String


The list of folders that exist under the specified folder, if any.

Type: Array of Folder objects


The list of submodules in the specified folder, if any.

Type: Array of SubModule objects

The list of symbolic links to other files and folders in the specified folder, if any.

Type: Array of SymbolicLink objects


The full SHA-1 pointer of the tree information for the commit that contains the folder.

Type: String


For information about the errors that are common to all actions, see Common Errors.


The specified commit does not exist or no commit was specified, and the specified repository has no default branch.

HTTP Status Code: 400


An encryption integrity check failed.

HTTP Status Code: 500


An encryption key could not be accessed.

HTTP Status Code: 400


The encryption key is disabled.

HTTP Status Code: 400


No encryption key was found.

HTTP Status Code: 400


The encryption key is not available.

HTTP Status Code: 400


The specified folder does not exist. Either the folder name is not correct, or you did not enter the full path to the folder.

HTTP Status Code: 400


The specified commit is not valid.

HTTP Status Code: 400


The specified path is not valid.

HTTP Status Code: 400


A specified repository name is not valid.


This exception occurs only when a specified repository name is not valid. Other exceptions occur when a required repository parameter is missing, or when a specified repository does not exist.

HTTP Status Code: 400


The folderPath for a location cannot be null.

HTTP Status Code: 400


The specified repository does not exist.

HTTP Status Code: 400


A repository name is required, but was not specified.

HTTP Status Code: 400



This example illustrates one usage of GetFolder.

Sample Request

POST / HTTP/1.1 Host: Accept-Encoding: identity Content-Length: 88 X-Amz-Target: CodeCommit_20150413.GetFolder X-Amz-Date: 20180914T222143Z User-Agent: aws-cli/1.15.9 Python/2.7.11 Darwin/16.7.0 botocore/1.10.9 Content-Type: application/x-amz-json-1.1 Authorization: AWS4-HMAC-SHA256 Credential=AKIAEXAMPLE/20180914/us-east-1/codecommit/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=0bcf747dEXAMPLE { "folderPath": "", "repositoryName": "MyDemoRepo" }

Sample Response

HTTP/1.1 200 OK x-amzn-RequestId: 8f9d4f13-EXAMPLE Content-Type: application/x-amz-json-1.1 Content-Length: 1157 Date: Fri, 14 Sep 2018 22:21:44 GMT Connection: keep-alive { "commitId":"c5709475EXAMPLE", "files":[ { "absolutePath":".gitignore", "blobId":"74094e8bEXAMPLE", "fileMode":"NORMAL", "relativePath":".gitignore" }, { "absolutePath":"Gemfile", "blobId":"9ceb72f6EXAMPLE", "fileMode":"NORMAL", "relativePath":"Gemfile" }, { "absolutePath":"Gemfile.lock", "blobId":"795c4a2aEXAMPLE", "fileMode":"NORMAL", "relativePath":"Gemfile.lock" }, { "absolutePath":"LICENSE.txt", "blobId":"0c7932c8EXAMPLE", "fileMode":"NORMAL", "relativePath":"LICENSE.txt" }, { "absolutePath":"", "blobId":"559b44feEXAMPLE", "fileMode":"NORMAL", "relativePath":"" } ], "folderPath":"", "subFolders":[ { "absolutePath":"public", "relativePath":"public", "treeId":"d5e92ae3aEXAMPLE" }, { "absolutePath":"tmp", "relativePath":"tmp", "treeId":"d564d0bcEXAMPLE" } ], "subModules":[], "symbolicLinks":[], "treeId":"7b3c4dadEXAMPLE" }

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: