---
agentTools:
  projectIndex: https://uspacy.readme.io/llms.txt
---

# Avatar upload

Avatar upload

# OpenAPI definition

````json
{
  "openapi": "3.1.0",
  "info": {
    "description": "This is [Uspacy](https://uspacy.com)  API documentation. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\nor on [irc.freenode.net, #swagger](http://swagger.io/irc/).\n\n# Introduction\nTo use this API you need to get Bearer token. To get Bearer token you have two options:\n  - sign in on user's Uspacy using email and password\n  - create Marketplace application and get token in callback after your application was installed by user\n\n# SDKs and boilerplates\nWe provide SDKs for different languages to simplify integration with Uspacy API. You can find them on [Uspacy GitHub](https://github.com/Uspacy/)\nWe have also prepared a few boilerplates to help you start developing your application\n  - [Uspacy Marketplace application boilerplate](https://github.com/Uspacy/app-laravel-template) - Laravel application with Uspacy authentication and token refreshment\n  - [Uspacy Golang SDK](https://github.com/Uspacy/uspacy-go-sdk) – Golang SDK for Uspacy API, in active development\n  - [Uspacy TypeScript SDK](https://github.com/Uspacy/uspacy-sdk) – TypeScript SDK for Uspacy API, deprecated\n\n# Marketplace applications development\nTo develop Marketplace application you need to create an application in Uspacy Marketplace. You can do it via request to [Uspacy support](mailto:support@uspacy.com).\nYou will receive ```client_id``` and ```client_secret``` for your application. You will also need to provide ```callback_url``` for your application.\nAfter that, the install/uninstall endpoints for your applications should be implemented. Please note that the path for these endpoints should follow this format:\n```{{callback_url}}/portals/install``` and ```{{callback_url}}/portals/uninstall```, respectively.\nFor example, if your ```callback_url``` is ```https://google.com/handler/v1```, we will send webhook to ```https://google.com/handler/v1/portals/install``` on install and ```https://google.com/handler/v1/portals/uninstall``` on uninstall.\nAfter a user installs your application, you will receive a POST request with JSON in the callback.\nThis will contain the ```token```, ```refresh_token```, and ```expiry_date``` fields.\nAdditionally, the ```integration_token``` will be provided as a Bearer token in the Authorization header.\nIt is signed using the ```client_secret``` and the SHA-256 algorithm. All future requests from your application's frontend to its backend should be secured with the ```integration_token```.\nThe ```integration_token``` is accessible through using the [appService](#tag/appService) for users with administrative rights.\nExample of request:\n```json\n{\n  \"expiry_date\": 1683649235,\n  \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEyMzEyMzEyMyIsImZpcnN0TmFtZSI6IlN0YXMiLCJsYXN0TmFtZSI6IlJhcmFuZXRza3lpIiwiZW1haWwiOiJyYXIuc3Rhc0BnbWFpbC5jb20iLCJyb2xlcyI6WyJVU0VSIiwiQURNSU4iLCJPV05FUiJdfQ.au16u5LHJqdvhiPrpXDhN4NZn8Cae09I6BEmed7mt8w\",\n  \"refresh_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEyMzEyMzEyMyIsImZpcnN0TmFtZSI6IlN0YXMiLCJsYXN0TmFtZSI6IlJhcmFuZXRza3lpIiwiZW1haWwiOiJyYXIuc3Rhc0BnbWFpbC5jb20iLCJyb2xlcyI6WyJVU0VSIiwiQURNSU4iLCJPV05FUiJdfQ.au16u5LHJqdvhiPrpXDhN4NZn8Cae09I6BEmed7mt8w\"\n}\n```\nYou need to save ```token```, ```refresh_token``` and ```expiry_date```  in your database. You will need to use ```token``` to make requests to Uspacy API. ```refresh_token``` is used to refresh ```token``` when it expires.\nYou should refresh the ```token``` before it expires. To do this, make a POST request to ```https://{domain}/auth/v1/auth/refresh_token/``` with the ```refresh_token``` in the body. The ```domain``` refers to the portal's domain that you received from the user's token headers upon application installation.\nYou will receive new ```jwt```, ```refreshToken``` and ```expireInSeconds``` in response. You need to save new ```token```, ```refresh_token``` and update ```expiry_date``` in your database.\n",
    "title": "Uspacy api",
    "version": "v1"
  },
  "servers": [
    {
      "url": "https://{domain}.uspacy.ua",
      "description": "Ukrainian server"
    },
    {
      "url": "https://{domain}.uspacy.eu",
      "description": "EU server"
    },
    {
      "url": "https://{domain}.uspacy.com.br",
      "description": "Brazilian server"
    },
    {
      "url": "https://{domain}.uspacy.com",
      "description": "International server"
    }
  ],
  "tags": [
    {
      "name": "usersService"
    }
  ],
  "paths": {
    "/company/v1/users/upload_avatar": {
      "post": {
        "summary": "Avatar upload",
        "description": "Avatar upload",
        "tags": [
          "usersService"
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "avatar"
                ],
                "properties": {
                  "avatar": {
                    "type": "string",
                    "format": "binary",
                    "example": "avatar.png file"
                  },
                  "userId": {
                    "type": "string",
                    "example": 2
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/User"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "responsibleId": {
                          "type": "string",
                          "example": 2
                        },
                        "denial": {
                          "type": "boolean",
                          "example": true
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "responses": {
      "UnauthorizedError": {
        "description": "Access token is missing or invalid"
      },
      "Forbidden": {
        "description": "Forbidden",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "errors": {
                  "type": "object",
                  "properties": {
                    "text": {
                      "type": "array",
                      "items": {
                        "example": "Forbidden message"
                      }
                    }
                  }
                },
                "status": {
                  "type": "boolean",
                  "example": true
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Roles": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "example": [
          "OWNER",
          "Employee",
          "ADMIN"
        ]
      },
      "multipleEmail": {
        "type": "array",
        "items": {
          "properties": {
            "id": {
              "type": "string",
              "example": "01gdnpddf5xgzxqvcn4x83mc2s"
            },
            "type": {
              "type": "string",
              "example": "main"
            },
            "value": {
              "type": "string",
              "example": "stark@gmail.com"
            },
            "main": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "example": [
          {
            "id": "",
            "type": "main",
            "value": "stark@gmail.com",
            "main": true
          },
          {
            "id": "01gdnpddf5xgzxqvcn4x83mc2s",
            "type": "work",
            "value": "benner@gmail.com",
            "main": false
          }
        ]
      },
      "Phone": {
        "type": "array",
        "items": {
          "properties": {
            "id": {
              "type": "string",
              "example": "01gdnpddf5xgzxqvcn4x83mc2s"
            },
            "type": {
              "type": "string",
              "enum": [
                "WORK",
                "MOBILE",
                "HOME"
              ],
              "example": "WORK"
            },
            "value": {
              "type": "string",
              "example": "+380123456789"
            }
          }
        }
      },
      "Date": {
        "type": "number",
        "description": "timestamp in seconds",
        "default": 0,
        "example": 1654180120
      },
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1
          },
          "firstName": {
            "type": "string",
            "example": "Stas"
          },
          "lastName": {
            "type": "string",
            "example": "Raranetskyi"
          },
          "patronymic": {
            "type": "string",
            "example": ""
          },
          "position": {
            "type": "string",
            "example": "CTO"
          },
          "specialization": {
            "type": "string",
            "example": "Specialist"
          },
          "country": {
            "type": "string",
            "example": "Ukraine"
          },
          "city": {
            "type": "string",
            "example": "Kiyv"
          },
          "avatar": {
            "type": "string",
            "example": "/storage/avatars/c4ca423/avatar.jpeg"
          },
          "aboutMyself": {
            "type": "string",
            "example": "about me"
          },
          "active": {
            "type": "boolean"
          },
          "registered": {
            "type": "boolean",
            "example": true
          },
          "birthday": {
            "$ref": "#/components/schemas/Date"
          },
          "dateOfDismiss": {
            "$ref": "#/components/schemas/Date"
          },
          "showBirthYear": {
            "type": "boolean",
            "default": false,
            "example": true
          },
          "email": {
            "$ref": "#/components/schemas/multipleEmail"
          },
          "phone": {
            "$ref": "#/components/schemas/Phone"
          },
          "roles": {
            "$ref": "#/components/schemas/Roles"
          },
          "departmentsIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "1",
              "2"
            ]
          },
          "socialMedia": {
            "$ref": "#/components/schemas/SocialMedia"
          },
          "emailInvitation": {
            "type": "boolean",
            "example": true
          },
          "dateOfInvitation": {
            "$ref": "#/components/schemas/Date"
          }
        }
      },
      "SocialMedia": {
        "type": "array",
        "items": {
          "properties": {
            "id": {
              "type": "string",
              "example": "01gdnpddf5xgzxqvcn4x83bn2s"
            },
            "name": {
              "type": "string",
              "example": "facebook"
            },
            "link": {
              "type": "string",
              "example": "https://www.facebook.com"
            }
          }
        }
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 101,
      "1": 36,
      "2": 32,
      "3": 193,
      "4": 231,
      "5": 38,
      "6": 198,
      "7": 0,
      "8": 19,
      "9": 99,
      "10": 232,
      "11": 3
    }
  }
}
````