- API-Referenz
- SSH/SFTP-Benutzer
- Create an SFTP user for a Project
Create an SFTP user for a Project
Request
- projectIdstringrequired
ID of the Project to create an SFTPUser for.
- accessLevelstring (einer von: read, full)
- authenticationeine von 2 Alternativenrequired
Method of authentication for an SFTPUser or SSHUser. Can be password or public-keys.
- Alternativeobject
- passwordstring (≤ 72 Zeichen)required
- Alternativeobject
- publicKeysArray von objectrequired
- Array[
A representation of an ssh-public-key.
- *object
A representation of an ssh-public-key.
- commentstringrequired
- keystringrequired
]
- descriptionstringrequired
- directoriesArray von stringrequired
- Array[
- *string
]
- expiresAtstring (date-time)
Content-Type: application/json
{
"accessLevel": "read",
"authentication": {
"password": "string"
},
"description": "string",
"directories": [
"string"
],
"expiresAt": "1985-10-26T01:21:00.000Z"
}
{
"properties": {
"accessLevel": {
"enum": [
"read",
"full"
],
"type": "string"
},
"authentication": {
"description": "Method of authentication for an SFTPUser or SSHUser. Can be password or public-keys.",
"oneOf": [
{
"properties": {
"password": {
"maxLength": 72,
"type": "string"
}
},
"required": [
"password"
],
"type": "object"
},
{
"properties": {
"publicKeys": {
"items": {
"description": "A representation of an ssh-public-key.",
"properties": {
"comment": {
"type": "string"
},
"key": {
"type": "string"
}
},
"required": [
"comment",
"key"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"publicKeys"
],
"type": "object"
}
]
},
"description": {
"type": "string"
},
"directories": {
"items": {
"type": "string"
},
"minItems": 1,
"type": "array"
},
"expiresAt": {
"format": "date-time",
"type": "string"
}
},
"required": [
"description",
"authentication",
"directories"
],
"type": "object"
}
Responses
Created
- accessLevelstring (einer von: full, read, unspecified)required
The level of access for an SFTPUser.
- activeboolean
- authUpdatedAtstring (date-time)required
- createdAtstring (date-time)required
- descriptionstringrequired
- detailedPublicKeysArray von object
- Array[
A representation of an ssh-public-key, enriched with information derived from the key.
- *object
A representation of an ssh-public-key, enriched with information derived from the key.
- algorithmstring
Absent if the key cannot be parsed.
- commentstringrequired
- fingerprintstring
SHA256 fingerprint in OpenSSH format, as printed by
ssh-keygen -l. Absent if the key cannot be parsed. - keystringrequired
]
- directoriesArray von string
- Array[
- *string
]
- expiresAtstring (date-time)
- hasPasswordbooleanrequired
- idstringrequired
- projectIdstringrequired
- publicKeysArray von objectdeprecated
deprecated by detailedPublicKeys
- Array[
A representation of an ssh-public-key.
- *object
A representation of an ssh-public-key.
- commentstringrequired
- keystringrequired
]
- updatedAtstring (date-time)
- userNamestringrequired
Content-Type: application/json
{
"accessLevel": "full",
"active": true,
"authUpdatedAt": "1985-10-26T01:21:00.000Z",
"createdAt": "1985-10-26T01:21:00.000Z",
"description": "string",
"detailedPublicKeys": [
{
"algorithm": "ssh-ed25519",
"comment": "string",
"fingerprint": "SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s",
"key": "string"
}
],
"directories": [
"string"
],
"expiresAt": "1985-10-26T01:21:00.000Z",
"hasPassword": true,
"id": "string",
"projectId": "string",
"updatedAt": "1985-10-26T01:21:00.000Z",
"userName": "string"
}
{
"description": "A representation of an SFTPUser.",
"properties": {
"accessLevel": {
"description": "The level of access for an SFTPUser.",
"enum": [
"full",
"read",
"unspecified"
],
"type": "string"
},
"active": {
"type": "boolean"
},
"authUpdatedAt": {
"format": "date-time",
"type": "string"
},
"createdAt": {
"format": "date-time",
"type": "string"
},
"description": {
"type": "string"
},
"detailedPublicKeys": {
"items": {
"description": "A representation of an ssh-public-key, enriched with information derived from the key.",
"properties": {
"algorithm": {
"description": "Absent if the key cannot be parsed.",
"example": "ssh-ed25519",
"type": "string"
},
"comment": {
"type": "string"
},
"fingerprint": {
"description": "SHA256 fingerprint in OpenSSH format, as printed by `ssh-keygen -l`. Absent if the key cannot be parsed.",
"example": "SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s",
"type": "string"
},
"key": {
"type": "string"
}
},
"required": [
"comment",
"key"
],
"type": "object"
},
"type": "array"
},
"directories": {
"items": {
"type": "string"
},
"type": "array"
},
"expiresAt": {
"format": "date-time",
"type": "string"
},
"hasPassword": {
"type": "boolean"
},
"id": {
"type": "string"
},
"projectId": {
"type": "string"
},
"publicKeys": {
"deprecated": true,
"description": "deprecated by detailedPublicKeys",
"items": {
"description": "A representation of an ssh-public-key.",
"properties": {
"comment": {
"type": "string"
},
"key": {
"type": "string"
}
},
"required": [
"comment",
"key"
],
"type": "object"
},
"type": "array"
},
"updatedAt": {
"format": "date-time",
"type": "string"
},
"userName": {
"type": "string"
}
},
"required": [
"id",
"projectId",
"description",
"userName",
"createdAt",
"authUpdatedAt",
"accessLevel",
"hasPassword"
],
"type": "object"
}
Validation Error caused by invalid input data in the request
- type"ValidationError"required
- messagestring
- validationErrorsArray von objectrequired
- Array[
- *object
- messagestringrequired
The standard error message
- pathstringrequired
The path to the part of the data that was validated. JavaScript property access notation (e.g., ".prop[1].subProp") is used.
- typestringrequired
ajv validation error type (e.g. "format", "required", "type") or own validation error types
- contextobject
The object with the additional information about the error that can be used to create custom error messages. Keys depend on the type that failed validation (e.g. "missingProperty" for type "required")
- *string
]
Content-Type: application/json
{
"type": "ValidationError",
"message": "Validation failed",
"validationErrors": [
{
"message": "should be string",
"path": ".address.street",
"type": "format",
"context": {
"format": "email"
}
}
]
}
{
"type": "object",
"required": [
"type",
"validationErrors"
],
"properties": {
"type": {
"type": "string",
"enum": [
"ValidationError"
]
},
"message": {
"type": "string",
"example": "Validation failed"
},
"validationErrors": {
"type": "array",
"items": {
"type": "object",
"required": [
"message",
"path",
"type"
],
"properties": {
"message": {
"type": "string",
"description": "The standard error message",
"example": "should be string"
},
"path": {
"type": "string",
"description": "The path to the part of the data that was validated. JavaScript property access notation (e.g., \".prop[1].subProp\") is used.\n",
"example": ".address.street"
},
"type": {
"type": "string",
"description": "ajv validation error type (e.g. \"format\", \"required\", \"type\") or own validation error types",
"example": "format"
},
"context": {
"type": "object",
"example": {
"format": "email"
},
"description": "The object with the additional information about the error that can be used to create custom error messages. Keys depend on the\ntype that failed validation (e.g. \"missingProperty\" for type \"required\")\n",
"additionalProperties": {
"type": "string"
}
}
}
}
}
}
}
An unexpected Error that occurred while handling the request
- messagestringrequired
- typestringrequired
Content-Type: application/json
{
"message": "Something went wrong",
"type": "InternalServerError"
}
{
"type": "object",
"required": [
"type",
"message"
],
"properties": {
"message": {
"type": "string",
"example": "Something went wrong"
},
"type": {
"type": "string",
"example": "InternalServerError"
}
}
}
Your request ran into a rate limit. You have to wait until rate limit expires
- messagestring
- typestring
Content-Type: application/json
{
"message": "too many requests",
"type": "RateLimitError"
}
{
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "too many requests"
},
"type": {
"type": "string",
"example": "RateLimitError"
}
}
}
An unexpected Error that occurred while handling the request
- messagestringrequired
- typestringrequired
Content-Type: application/json
{
"message": "Something went wrong",
"type": "InternalServerError"
}
{
"type": "object",
"required": [
"type",
"message"
],
"properties": {
"message": {
"type": "string",
"example": "Something went wrong"
},
"type": {
"type": "string",
"example": "InternalServerError"
}
}
}
Nutzungsbeispiele
$ curl \
--fail \
--location \
-X POST \
-d '{"accessLevel":"read","authentication":{"password":"string"},"description":"string","directories":["string"],"expiresAt":"1985-10-26T01:21:00.000Z"}' \
-H "Authorization: Bearer $MITTWALD_API_TOKEN" \
-H 'Content-Type: application/json' \
https://api.mittwald.de/v2/projects/string/sftp-users
import { MittwaldAPIV2Client } from "@mittwald/api-client";
import { assertStatus } from "@mittwald/api-client-commons";
const client = MittwaldAPIClient.newWithToken(process.env.MITTWALD_API_TOKEN);
const response = await client.sshsftpUser.sftpUserCreateSftpUser({
"projectId": "string",
"data": {
"accessLevel": "read",
"authentication": {
"password": "string"
},
"description": "string",
"directories": [
"string"
],
"expiresAt": "1985-10-26T01:21:00.000Z"
}
});
assertStatus(response, 201);
use \Mittwald\ApiClient\Generated\V2\Clients\SSHSFTPUser\SftpUserCreateSftpUser\SftpUserCreateSftpUserRequest;
use \Mittwald\ApiClient\Generated\V2\Clients\SSHSFTPUser\SftpUserCreateSftpUser\SftpUserCreateSftpUserRequestBody;
$client = MittwaldAPIClient::newWithToken(getenv('MITTWALD_API_TOKEN'));
// TODO: Please consult the properties and constructor signature of
// SftpUserCreateSftpUserRequestBody to learn how to construct a valid instance
$body = new SftpUserCreateSftpUserRequestBody(/* TODO: ... */);
$request = (new SftpUserCreateSftpUserRequest(
projectId: "string",
body: $body
));
$response = $client->sshsftpUser()->sftpUserCreateSftpUser($request);
var_dump($response->getBody();